Skip to content

Commit

Permalink
feat: Custom lexicon to add company products
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlesne committed Jan 15, 2024
1 parent c6634f8 commit edc38fa
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -178,7 +179,10 @@ make install

Also, 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)

### Run

Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
20 changes: 20 additions & 0 deletions resources/lexicon.xml
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit edc38fa

Please sign in to comment.