Skip to content

Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!

Python

feat: Add custom neural voice compatibility

Clémence Lesné622602e08a8c
diff --git a/README.md b/README.md
index c97163c..2d6221a 100644
--- a/README.md
+++ b/README.md
@@ -453,6 +453,23 @@ conversation:
voice: "zh-CN-XiaoqiuNeural"
```
+If you built and deployed an [Azure Speech Custom Neural Voice (CNV)](https://learn.microsoft.com/en-us/azure/ai-services/speech-service/custom-neural-voice), add field `custom_voice_endpoint_id` on the language configuration:
+
+```yaml
+# config.yaml
+[...]
+
+conversation:
+ initiate:
+ lang:
+ default_short_code: fr-FR
+ availables:
+ - pronunciations_en: ["French", "FR", "France"]
+ short_code: fr-FR
+ voice: xxx
+ custom_voice_endpoint_id: xxx
+```
+
### Customize the moderation levels
Levels are defined for each category of Content Safety. The higher the score, the more strict the moderation is, from 0 to 7. Moderation is applied on all bot data, including the web page and the conversation. Configure them in Azure OpenAI Content Filters.
diff --git a/helpers/call_utils.py b/helpers/call_utils.py
index 474a573..36a6e6d 100644
--- a/helpers/call_utils.py
+++ b/helpers/call_utils.py
@@ -348,7 +348,10 @@ def _audio_from_text(
</voice>
</speak>
"""
- return SsmlSource(ssml_text=ssml.strip())
+ return SsmlSource(
+ custom_voice_endpoint_id=call.lang.custom_voice_endpoint_id,
+ ssml_text=ssml.strip(),
+ )
async def handle_recognize_ivr(
diff --git a/helpers/config_models/conversation.py b/helpers/config_models/conversation.py
index 9f38c4c..da63d61 100644
--- a/helpers/config_models/conversation.py
+++ b/helpers/config_models/conversation.py
@@ -15,6 +15,7 @@ class LanguageEntryModel(BaseModel):
See: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/language-support?tabs=tts#supported-languages
"""
+ custom_voice_endpoint_id: Optional[str] = None
pronunciations_en: list[str]
short_code: str
voice: str