Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!
Python
feat: Custom lexicon to add company products
Clémence Lesnéedc38fa68fa2
diff --git a/README.md b/README.mdindex cc277ce..46af94e 100644--- a/README.md+++ b/README.md@@ -47,6 +47,7 @@ Extract of the data stored during the call:- [x] Access to customer conversation history- [x] Bot can be called from a phone number+- [x] Company products (= lexicon) can be understood by the bot (e.g. a name of a specific insurance product)- [x] Create by itself a todo list of tasks to complete the claim- [x] Disengaging from a human agent when needed- [x] Fine understanding of the customer request with GPT-4 Turbo@@ -178,7 +179,10 @@ make installAlso, a public file server is needed to host the audio files.-For this, you can use Azure Blob Storage. In that case, content of the project folder `resources` requires to be uploaded to the public container `$web` of the storage account.+For this, you can use Azure Blob Storage. In that case, content of the project folder `resources` requires to be uploaded to the public container `$web` of the storage account. This folder contains:++- Audio files (`xxx.wav`) to be played during the call+- [Lexicon file (`lexicon.xml`)](https://learn.microsoft.com/en-us/azure/ai-services/speech-service/speech-synthesis-markup-pronunciation#custom-lexicon) to be used by the bot to understand the company products (note: any change [makes up to 15 minutes](https://learn.microsoft.com/en-us/azure/ai-services/speech-service/speech-synthesis-markup-pronunciation#custom-lexicon-file) to be taken into account)### Rundiff --git a/main.py b/main.pyindex cd988ee..27d89b7 100644--- a/main.py+++ b/main.py@@ -922,7 +922,7 @@ def audio_from_text(text: str) -> SsmlSource:f"Text is too long to be processed by TTS, truncating to 400 characters, fix this!")text = text[:400]- ssml = f'<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="{CONFIG.workflow.conversation_lang}"><voice name="{CONFIG.communication_service.voice_name}" effect="eq_telecomhp8k"><prosody rate="0.95">{text}</prosody></voice></speak>'+ ssml = f'<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="{CONFIG.workflow.conversation_lang}"><voice name="{CONFIG.communication_service.voice_name}" effect="eq_telecomhp8k"><lexicon uri="{CONFIG.resources.public_url}/lexicon.xml"/><prosody rate="0.95">{text}</prosody></voice></speak>'return SsmlSource(ssml_text=ssml)diff --git a/resources/lexicon.xml b/resources/lexicon.xmlnew file mode 100644index 0000000..018ea4a--- /dev/null+++ b/resources/lexicon.xml@@ -0,0 +1,20 @@+<?xml version="1.0" encoding="UTF-8"?>+<lexicon version="1.0" xmlns="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2005/01/pronunciation-lexicon http://www.w3.org/TR/2007/CR-pronunciation-lexicon-20071212/pls.xsd" alphabet="ipa" xml:lang="fr-FR">+ <!-- Exemples de contrats d'assurance auto -->+ <lexeme>+ <grapheme>contrat mini</grapheme>+ <alias>assurance voiture au tiers, qui dispose du minimum légal</alias>+ </lexeme>+ <lexeme>+ <grapheme>contrat eco</grapheme>+ <alias>assurance voiture au tiers, qui inclut en plus les garanties vol, incendie et bris de glace</alias>+ </lexeme>+ <lexeme>+ <grapheme>contrat confort</grapheme>+ <alias>assurance voiture tous risques, qui inclut la couverture tous accidents (responsables ou subis)</alias>+ </lexeme>+ <lexeme>+ <grapheme>contrat mobilité</grapheme>+ <alias>assurance voiture tous risques, qui inclut les pannes mécaniques, l'assistance 0km et le véhicule de remplacement tous accident/panne/vol</alias>+ </lexeme>+</lexicon>