File size: 712 Bytes
c4987e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from rtc.openai_stt import OpenAISTTModel
from rtc.openai_tts import OpenAITTSModel
from rtc.rtc_call import RTCHandler
from config.constant import OPENAI_API_KEY
stt_model = OpenAISTTModel(
            api_key=OPENAI_API_KEY,
            model="whisper-1",
            language="en",  # Set to your preferred language
            response_format="text")
tts_model = OpenAITTSModel(
            api_key=OPENAI_API_KEY,
            model="tts-1",  # Use "tts-1-hd" for higher quality
            voice="alloy",  # Choose: alloy, echo, fable, onyx, nova, shimmer
            response_format="mp3",
            speed=1.0)
def handle_rtc():
    rtc_call = RTCHandler(stt_model, tts_model)
    rtc_call.start_stream()