feat: implement VoiceService with multi-model speech-to-text and text-to-speech capabilities
This commit is contained in:
@@ -121,8 +121,8 @@ class VoiceService:
|
||||
and lang_prefix in ["ta", "hi", "te", "kn", "bn", "mr", "gu", "ml", "pa", "od", "en"]
|
||||
):
|
||||
try:
|
||||
speaker = "anushka" if lang_prefix in ["ta", "hi", "te", "kn"] else "karun"
|
||||
async with httpx2.AsyncClient(timeout=3.0) as client:
|
||||
speaker = "kavya" if lang_prefix in ["ta", "hi", "te", "kn"] else "gokul"
|
||||
async with httpx2.AsyncClient(timeout=5.0) as client:
|
||||
headers = {
|
||||
"api-subscription-key": self.sarvam_key,
|
||||
"Content-Type": "application/json",
|
||||
@@ -131,7 +131,7 @@ class VoiceService:
|
||||
"inputs": [cleaned_text],
|
||||
"target_language_code": language_code,
|
||||
"speaker": speaker,
|
||||
"model": "bulbul:v2",
|
||||
"model": "bulbul:v3",
|
||||
}
|
||||
res = await client.post(
|
||||
"https://api.sarvam.ai/text-to-speech",
|
||||
@@ -153,7 +153,7 @@ class VoiceService:
|
||||
|
||||
# 2. Use OpenAI TTS
|
||||
if self.openai_key and self.openai_key.strip() not in ["your_openai_api_key", "your_openai_key", ""]:
|
||||
client = AsyncOpenAI(api_key=self.openai_key, timeout=1.5)
|
||||
client = AsyncOpenAI(api_key=self.openai_key, timeout=5.0)
|
||||
try:
|
||||
response = await client.audio.speech.create(
|
||||
model="tts-1",
|
||||
|
||||
Reference in New Issue
Block a user