Preparing the spoken response
You've made it to the final step of the case study! Your task now is to convert the tailored, translated response into speech. Since the customer submitted their query via audio, they'll receive an audio reply in return—how cool is that?
The translated reply from the previous exercise is available as translated_reply.
Bu egzersiz
Multi-Modal Systems with the OpenAI API
kursunun bir parçasıdırEgzersiz talimatları
- Use the
gpt-4o-mini-ttsmodel with the"onyx"voice to create a speech request fortranslated_reply. - Stream the response to an
.mp3file.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
client = OpenAI(api_key="")
# Create the text-to-speech request
response = ____
# Stream the response to an MP3 file
response.____("output.mp3")