2017-06-19 3 views
0

J'essaye d'écrire un programme pour la synthèse vocale à l'aide de Microsoft SAPI. Pour cela, je le code suivant:Parler événement de progression dans SAPI

ISpVoice * pVoice = NULL; 

int main(int argc, char* argv[]) 
{ 

    if (FAILED(::CoInitialize(NULL))) 
     return FALSE; 

    HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice); 
    if (SUCCEEDED(hr)) 
    { 
     hr = pVoice->Speak(L"Anyone who reads Old and Middle English literary texts will be familiar with the mid-brown volumes of the EETS, with the symbol of Alfred's jewel embossed on the front cover. Most of the works attributed to King Alfred or to Aelfric, along with some of those by bishop Wulfstan and much anonymous prose and verse from the pre-Conquest period, are to be found within the Society's three series; all of the surviving medieval drama, most of the Middle English romances, much religious and secular prose and verse including the English works of John Gower, Thomas Hoccleve and most of Caxton's prints all find their place in the publications. Without EETS editions, study of medieval English texts would hardly be possible.", SPF_IS_XML, NULL); 
     pVoice->Release(); 
     pVoice = NULL; 
    } 
    ::CoUninitialize(); 
    return TRUE; 
} 

Je veux imprimer les progrès de parler à l'écran, l'impression de chaque mot quand il parle. Semblable à cela dans System.Speech.Synthesis:

synth.SpeakProgress += new EventHandler<SpeakProgressEventArgs>(synth_SpeakProgress); 

Pour plus de détails: Use Speech Synthesis Events

Alors, comment puis-je faire en utilisant SAPI?

Répondre

0

ISpVoice hérite de ISpEventSource, qui à son tour hérite de ISpNotifySource.

utiliser la méthode ISpEventSource::SetInterest() pour enregistrer des événements désirés, tels que SPEI_WORD_BOUNDARY:

Un mot commence à synthétiser. Les marqueurs de langage de balisage (XML) sont comptés dans les limites et les décalages. wParam est la longueur de caractère du mot dans le flux d'entrée courant en cours de synthèse. lParam est la position du caractère dans le flux d'entrée de texte en cours du mot en cours de synthèse.

Utilisez les différentes ISpNotifySource::SetNotify...() méthodes pour spécifier la façon dont vous souhaitez recevoir des événements de SAPI:

Lorsque vous recevez une notification de nouveaux événements, utilisez ISpEventSource::GetEvents() pour obtenir des informations d'événement détaillé, le cas échéant.