mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-07-01 08:59:46 +02:00
fix: add text filter for tts and logs for filter
This commit is contained in:
parent
570168424a
commit
003039ca56
3 changed files with 21 additions and 3 deletions
|
|
@ -17,6 +17,7 @@ from pipecat.services.groq.llm import GroqLLMService
|
|||
from pipecat.services.openai.llm import OpenAILLMService
|
||||
from pipecat.services.openai.stt import OpenAISTTService
|
||||
from pipecat.services.openai.tts import OpenAITTSService
|
||||
from pipecat.utils.text.xml_function_tag_filter import XMLFunctionTagFilter
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from api.services.pipecat.audio_config import AudioConfig
|
||||
|
|
@ -65,13 +66,19 @@ def create_tts_service(user_config, audio_config: "AudioConfig"):
|
|||
user_config: User configuration containing TTS settings
|
||||
transport_type: Type of transport (e.g., 'stasis', 'twilio', 'webrtc')
|
||||
"""
|
||||
# Create function call filter to prevent TTS from speaking function call tags
|
||||
xml_function_tag_filter = XMLFunctionTagFilter()
|
||||
if user_config.tts.provider == ServiceProviders.DEEPGRAM.value:
|
||||
return DeepgramTTSService(
|
||||
api_key=user_config.tts.api_key, voice=user_config.tts.voice.value
|
||||
api_key=user_config.tts.api_key,
|
||||
voice=user_config.tts.voice.value,
|
||||
text_filters=[xml_function_tag_filter]
|
||||
)
|
||||
elif user_config.tts.provider == ServiceProviders.OPENAI.value:
|
||||
return OpenAITTSService(
|
||||
api_key=user_config.tts.api_key, model=user_config.tts.model.value
|
||||
api_key=user_config.tts.api_key,
|
||||
model=user_config.tts.model.value,
|
||||
text_filters=[xml_function_tag_filter]
|
||||
)
|
||||
elif user_config.tts.provider == ServiceProviders.ELEVENLABS.value:
|
||||
voice_id = user_config.tts.voice.split(" - ")[1]
|
||||
|
|
@ -83,6 +90,7 @@ def create_tts_service(user_config, audio_config: "AudioConfig"):
|
|||
params=ElevenLabsTTSService.InputParams(
|
||||
stability=0.8, speed=user_config.tts.speed, similarity_boost=0.75
|
||||
),
|
||||
text_filters=[xml_function_tag_filter]
|
||||
)
|
||||
elif user_config.tts.provider == ServiceProviders.DOGRAH.value:
|
||||
# Convert HTTP URL to WebSocket URL for TTS
|
||||
|
|
@ -93,6 +101,7 @@ def create_tts_service(user_config, audio_config: "AudioConfig"):
|
|||
api_key=user_config.tts.api_key,
|
||||
model=user_config.tts.model.value,
|
||||
voice=user_config.tts.voice.value,
|
||||
text_filters=[xml_function_tag_filter]
|
||||
)
|
||||
else:
|
||||
raise HTTPException(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue