Multi-Modal Systems with the OpenAI API
James Chapman
Curriculum Manager, DataCamp
$$
$$
$$
$$
$$
print(language)
uk
$$
print(chatbot_reply)
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": f"""Translate the following text
from English to country code {language}. Only return the translated text!"""},
{"role": "user", "content": chatbot_reply}
],
max_completion_tokens=500)
# Extract and print the translated response
translated_reply = response.choices[0].message.content
print(translated_reply)
response = client.audio.speech.create( model="gpt-4o-mini-tts", voice="onyx", input=translated_reply)
response.stream_to_file("audio_reply.mp3")
Multi-Modal Systems with the OpenAI API