14
1 11/18/2 11/18/2 010 010 F. Gaillard F. Gaillard François Gaillard francois point gaillard à gmail point com http://fgaillard.com Synthèse et reconnaisance de la parole Synthèse et reconnaisance de la parole avec Delphi avec Delphi Delphi Speech Delphi Speech

111/18/2010 F. Gaillard François Gaillard francois point gaillard à gmail point com Synthèse et reconnaisance de la parole avec Delphi

Embed Size (px)

Citation preview

Page 1: 111/18/2010 F. Gaillard François Gaillard francois point gaillard à gmail point com  Synthèse et reconnaisance de la parole avec Delphi

1111/18/201011/18/2010F. GaillardF. Gaillard

François Gaillardfrancois point gaillard à gmail point comhttp://fgaillard.com

Synthèse et reconnaisance de la paroleSynthèse et reconnaisance de la paroleavec Delphiavec Delphi

Delphi SpeechDelphi Speech

Page 2: 111/18/2010 F. Gaillard François Gaillard francois point gaillard à gmail point com  Synthèse et reconnaisance de la parole avec Delphi

2211/18/201011/18/2010F. GaillardF. Gaillard

Agenda

• Vue d’ensemble• Synthese• Dictee• Contrôle• RichEdit 4.1• Delphi Prism

Delphi SpeechDelphi Speech

Page 3: 111/18/2010 F. Gaillard François Gaillard francois point gaillard à gmail point com  Synthèse et reconnaisance de la parole avec Delphi

3311/18/201011/18/2010F. GaillardF. Gaillard

Architecture

Delphi SpeechDelphi Speech

Recognition EnginesTTS Engines

SAPI runtime

Speech API

ApplicationApplication Application

Page 4: 111/18/2010 F. Gaillard François Gaillard francois point gaillard à gmail point com  Synthèse et reconnaisance de la parole avec Delphi

4411/18/201011/18/2010F. GaillardF. Gaillard

Un peu d’histoire (récente)

Delphi SpeechDelphi Speech

SAPI 5.1 Fin 2001. Inclus dans le Speech SDK v5.1. API + Moteurs de synthèse vocale (Mike and Mary) pour Windows XP. API + Moteur de reconnaissance v6 TRES amélioré pour Office 2003 (+ L&H Michael & Michelle) et Windows XP Tablet PC.

SAPI 5.22004. Version spéciale de l'API spécialement pour Microsoft Speech Server. Support pour Speech Recognition Grammar Specification (SRGS) and SSML mark-up languages, fonctionnalités serveurs and performance. Speech Server inclus la v6 du moteur de reconnaissance desktop and la v7 du moteur serveur.

SAPI 5.3 = Refonte majeureAPI incluse dans Windows Vista avec de nouveaux moteurs pour la reconnaissance (Version 8) and la synthèse (Anna). Reconnaissance vocale complètement intégrée dans l'OS=> Speech SDK et APIs inclus dans le Windows SDK général.

SAPI 5.4Mise a jour pour Windows 7.

Page 5: 111/18/2010 F. Gaillard François Gaillard francois point gaillard à gmail point com  Synthèse et reconnaisance de la parole avec Delphi

5511/18/201011/18/2010F. GaillardF. Gaillard

Synthèse

• Facile, résultat rapide– Bien pour «late binding» (pas besoin de Type Library)– Seulement besoin de quelques méthodes ou propriétés– Très amélioré dans Vista (SAPI 5.3), et Win7 (SAPI 5.4)

• Exemple d’application avec très peu de code• Attention au piège Vista (& Win7)• Lecture en français avec Speech Server• Application de lecture ReadAloud

– Message d’erreur sonore– Lecteur– Jouer avec les paramètres et XML(SSML)

Delphi SpeechDelphi Speech

Page 6: 111/18/2010 F. Gaillard François Gaillard francois point gaillard à gmail point com  Synthèse et reconnaisance de la parole avec Delphi

6611/18/201011/18/2010F. GaillardF. Gaillard

Flags TTS• SVSFDefault: pour utiliser les valeurs par defaut.

– synthèse synchrone (outrepasser avec SVSFlagsAsync),– Sans purge des lectures en attente (outrepasser avec SVSFPurgeBeforeSpeak),– Interpréter le texte comme XML seulement si le 1er caractère est "<" (outrepasser avecSVSFIsXML ou SVSFIsNotXML),– Changements globaux XML volatiles entre les appels (outrepasser avec SVSFPersistXML)– Caractères de ponctuation silencieux (outrepasser avec SVSFNLPSpeakPunc).

• SVSFlagsAsync: Appels asynchrones. Rend la main immédiatement après la mise en file de la requête. • SVSFPurgeBeforeSpeak: Purge toutes les requêtes en attente avant cet appel.• SVSFIsFilename: Le texte passe en paramètre est un nom de fichier et non un texte à lire. C’est le fichier désigné

dont le contenu est lu, pas la chaine elle-même.• SVSFIsXML: Le texte entré est interprété comme XML.• SVSFIsNotXML: Le texte entré n’est pas interprété comme XML.• SVSFPersistXML: Les changements globaux passés par XML persistent entre les appels.• SVSFNLPSpeakPunc: Les caractères de ponctuation sont prononcés ("Voilà." devient " Voilà point").• SVSFParseSapi: Force interprétation XML comme MS SAPI.• SVSFParseSsml: Force interprétation XML comme W3C SSML.• SVSFParseAutoDetect: Auto-détection XML. Par défaut, si aucun de ces flags n’est inclus.• SVSFNLPMask: Flags utilisés par SAPI (et non pas le moteur de synthèse).• SVSFParseMask: SVSFParseSapi|SVSFParseSsml• SVSFVoiceMask: Masque SAPI 5.1 incluant tous les bits. Pour 5.3, il inclut aussi SVSFParseMask.• SVSFUnusedFlags: Masque avec tous les bits non définis mis à 1.

Delphi SpeechDelphi Speech

Page 7: 111/18/2010 F. Gaillard François Gaillard francois point gaillard à gmail point com  Synthèse et reconnaisance de la parole avec Delphi

7711/18/201011/18/2010F. GaillardF. Gaillard

SAPI XML TTS• Balises de contrôle d‘état de la Voix

– Volume: 0..100 (%)<volume level="50">Spoken at volume level fifty.</volume><volume level="80"/>Spoken at volume level eighty from here.

– Rate: -10..10 (0: débit normal, >0 plus rapide, <0 plus lent)• absspeed: fixe une valeur absolue• speed: augmente ou diminue la vitesse

– Pitch: -10..10 (0: hauteur normale, >0 plus aigue, <0 plus grave)• absmiddle:• middle:

– Emph: emphase pour une portion de texte <emph> boo </emph>!

– Spell: force la voix a épeler les texte<spell>These words should be spelled out.</spell>

Note: emph and spell ne peuvent pas etre vides (pour la suite du texte)Pour Speech Server compatibilité, voir:http://msdn.microsoft.com/en-us/library/dd450827(v=office.13).aspx

Delphi SpeechDelphi Speech

Page 8: 111/18/2010 F. Gaillard François Gaillard francois point gaillard à gmail point com  Synthèse et reconnaisance de la parole avec Delphi

8811/18/201011/18/2010F. GaillardF. Gaillard

SAPI XML TTS• Balise d’insertion directe

– Silence: insert un silence en ms<silence msec="500"/>

– Bookmark: insert un marqueur dans le flux de sortie audio. Déclenche un événement dans l’application lorsque le flux l’atteint.<bookmark mark="bookmark_one"/>

– Pron: insert une prononciation explicitée par des phonèmes <pron sym="h eh 1 l ow & w er 1 l d "/><pron sym="h eh 1 l ow & w er 1 l d"> hello world </pron>

SYM Example PhoneID

- syllable boundary (hyphen) 1

! Sentence terminator (exclamation mark) 2

& word boundary 3

, Sentence terminator (comma) 4

. Sentence terminator (period) 5

? Sentence terminator (question mark) 6

_ Silence (underscore) 7

1 Primary stress 8

Delphi SpeechDelphi Speech

Page 9: 111/18/2010 F. Gaillard François Gaillard francois point gaillard à gmail point com  Synthèse et reconnaisance de la parole avec Delphi

9911/18/201011/18/2010F. GaillardF. Gaillard

SAPI XML TTS

Delphi SpeechDelphi Speech

• American English Phoneme TableSYM Example PhoneID

2 Secondary stress 9

aa father 10

ae cat 11

ah cut 12

ao dog 13

aw foul 14

ax ago 15

ay bite 16

b big 17

ch chin 18

d dig 19

dh then 20

eh pet 21

er fur 22

ey ate 23

f fork 24

g gut 25

h help 26

Page 10: 111/18/2010 F. Gaillard François Gaillard francois point gaillard à gmail point com  Synthèse et reconnaisance de la parole avec Delphi

101011/18/201011/18/2010F. GaillardF. Gaillard

Dictée

• Importer la Speech Type Library (plus pratique)• Activer la reconnaissance vocale sur votre ordinateur• Et l’entrainer: Faites le tutorial!

– Rapide– Amusant– Vraiment efficace

• Application Dictée:• Comment remplir un Memo sans clavier en 10 lignes

de code

Delphi SpeechDelphi Speech

Page 11: 111/18/2010 F. Gaillard François Gaillard francois point gaillard à gmail point com  Synthèse et reconnaisance de la parole avec Delphi

111111/18/201011/18/2010F. GaillardF. Gaillard

Contrôle

• Définir une Grammaire• Application Dictée (le retour)• Comment contrôler votre Memo en moins de 10

lignes de code

Delphi SpeechDelphi Speech

Page 12: 111/18/2010 F. Gaillard François Gaillard francois point gaillard à gmail point com  Synthèse et reconnaisance de la parole avec Delphi

121211/18/201011/18/2010F. GaillardF. Gaillard

RichEdit 4.1 http://fgaillard.com/2010/09/using-richedit-4-1-with-d2010/ • Meilleure compatibilité graphique• Capacités vocales améliorées (go to start of sentence)• unit ComCtrls;• {$define richedit41} // FG. try to load enhanced RichEdit• {$ifdef richedit41}• RichEditModuleName = 'MSFTEDIT.DLL';• OldRichEditModuleName = 'RICHED20.DLL';• {$else}• RichEditModuleName = 'RICHED20.DLL';• {$endif}• {$ifdef richedit41} IsRichEdit41: Boolean; {$endif}• NewRichEditClassName = 'RICHEDIT50W';• RichEditClassName = 'RICHEDIT20W';• {$ifdef richedit41}• if IsRichEdit41 then• CreateSubClass(Params, NewRichEditClassName)• else• {$endif}

Delphi SpeechDelphi Speech

Page 13: 111/18/2010 F. Gaillard François Gaillard francois point gaillard à gmail point com  Synthèse et reconnaisance de la parole avec Delphi

131311/18/201011/18/2010F. GaillardF. Gaillard

Delphi Prism

• Project | add reference: System.Speech / Microsoft.Speech

• Uses: System.Speech.Synthesis / Microsoft.Speech.Synthesis

• Create a new SpeechSynthesizer– FVoice := new SpeechSynthesizer();

• Set properties Rate and Volume– FVoice.Volume := Integer(edtVolume.Value);– FVoice.Rate := Integer(edtRate.Value);

• Speak– FVoice.SpeakAsync(richTextBox1.Text);

Delphi SpeechDelphi Speech

Page 14: 111/18/2010 F. Gaillard François Gaillard francois point gaillard à gmail point com  Synthèse et reconnaisance de la parole avec Delphi

141411/18/201011/18/2010F. GaillardF. Gaillard

Autres infosAutres infosMicrosoft SpeechMicrosoft Speech http://msdn.microsoft.com/en-us/library/ee721044.aspxhttp://msdn.microsoft.com/en-us/library/ee721044.aspx

Microsoft Speech API (SAPI) 5.4Microsoft Speech API (SAPI) 5.4 http://msdn.microsoft.com/en-us/library/ee125663(v=VS.85).aspxhttp://msdn.microsoft.com/en-us/library/ee125663(v=VS.85).aspx

Mon blogMon blog http://fgaillard.com/tag/speechhttp://fgaillard.com/tag/speech

Difference System.Speech.Recognition / Microsoft.Speech.RecognitionDifference System.Speech.Recognition / Microsoft.Speech.Recognitionhttp://social.msdn.microsoft.com/Forums/en/ucmanagedsdk/thread/39ec282d-cc51-49c7-http://social.msdn.microsoft.com/Forums/en/ucmanagedsdk/thread/39ec282d-cc51-49c7-

9686-0e4d3f9b85169686-0e4d3f9b8516

Delphi SpeechDelphi Speech

François GaillardFrancois point gaillard à gmail point comhttp://fgaillard.com