...
SpInProcRecoContext1: TSpInProcRecoContext;
SpObjectToken1: TSpObjectToken;
...
SpVoice: Variant;
objAudioTokenCategory : TSpObjectTokenCategory ;
objAudioToken,
objEngineToken,
objProfileToken : ISpeechObjectToken;
function startVoice: Integer;
function stopVoice: Integer;
...
//------------------------------------------------------------------------------
// start voice
function TDM_Voice.startVoice: Integer;
var
MyTokenCategory: WideString;
begin
try
SpInProcRecoContext1.EventInterests := SREAllEvents;
MyTokenCategory := '
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\AudioInput';
// SpeechCategoryAudioIn
objAudioTokenCategory := TSpObjectTokenCategory.Create(
Nil) ;
objAudioTokenCategory.SetId(MyTokenCategory , false);
objAudioToken := ISpeechObjectToken(objAudioTokenCategory.DefaultInterface);
objAudioToken.SetId(objAudioTokenCategory.
Default, MyTokenCategory, false);
try
MyTokenCategory := '
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Recognizers';
// SpeechCategoryRecognizers
objAudioTokenCategory.SetId(MyTokenCategory , false);
except
on E:
Exception do begin // OLE-Fehler 80045002 > schon vorhanden also kein Fehler
Logdatent_Schreiben('
Fehler in StartVoice Fehler:' +E.
Message);
end;
end;
objEngineToken := ISpeechObjectToken(objAudioTokenCategory.DefaultInterface);
objEngineToken.SetId(objAudioTokenCategory.
Default, MyTokenCategory, false);
try
MyTokenCategory := '
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Speech\RecoProfiles';
// SpeechCategoryRecoProfiles
objAudioTokenCategory.SetId(MyTokenCategory , false);
except
on E:
Exception do begin // OLE-Fehler 80045002 > schon vorhanden also kein Fehler
Logdatent_Schreiben('
Fehler in StartVoice Fehler:' +E.
Message);
end;
end;
objProfileToken := ISpeechObjectToken(objAudioTokenCategory.DefaultInterface);
objProfileToken.SetId(objAudioTokenCategory.
Default, MyTokenCategory, false);
SpInProcRecoContext1.Recognizer.AudioInput := objAudioToken;
// Fehler falscher Parameter Warum :oops:????
SpInProcRecoContext1.Recognizer.Profile := objProfileToken;
SpInProcRecoContext1.Recognizer.CreateRecoContext;
SpInProcRecoContext1.Connect;
Logdatent_Schreiben('
Starte Voice');
except
on E:
Exception do begin
Logdatent_Schreiben('
Fehler in StartVoice Fehler:' +E.
Message);
end;
end;
end;