私はデルファイでいくつかの音声認識を実行しようとしていますが、これは素晴らしいプロジェクトですが、SAPI 5.1をインポートできないため使用できません。
「インポートタイプライブラリ」ウィンドウでSAPI 5.4を見つけることができますが、悲しいことに、それを処理することができませんでした。今私はSAPI 5.1をインポートする方法があるかどうか疑問に思っていますので、私は以下の例を使用して私のニーズに合わせて拡張することができます。すべてのヘルプは高く評価されデルファイはSAPIをインポートできません5.1
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, SpeechLib_TLB, StdCtrls;
const SP_GETWHOLEPHRASE = -1;
type
TForm3 = class(TForm)
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private-Deklarationen }
public
SpSharedRecoContext1: TSpSharedRecoContext;
MyGrammar : ISpeechRecoGrammar;
procedure SpSharedRecoContext1Recognition(ASender: TObject;
StreamNumber: Integer;
StreamPosition: OleVariant;
RecognitionType: SpeechRecognitionType;
const Result: ISpeechRecoResult);
procedure SpSharedRecoContext1Hypothesis(ASender: TObject;
StreamNumber: Integer;
StreamPosition: OleVariant;
const Result: ISpeechRecoResult);
{ Public-Deklarationen }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
begin
SpSharedRecoContext1.Free;
end;
procedure TForm3.FormCreate(Sender: TObject);
begin
SpSharedRecoContext1 := TSpSharedRecoContext.Create(self);
SpSharedRecoContext1.OnRecognition := SpSharedRecoContext1Recognition;
SpSharedRecoContext1.OnHypothesis := SpSharedRecoContext1Hypothesis;
MyGrammar := SpSharedRecoContext1.CreateGrammar(0);
MyGrammar.DictationSetState(SGDSActive);
end;
procedure TForm3.SpSharedRecoContext1Recognition(ASender: TObject;
StreamNumber: Integer;
StreamPosition: OleVariant;
RecognitionType: SpeechRecognitionType;
const Result: ISpeechRecoResult);
begin
Caption := '';
Memo1.Lines.Add(Result.PhraseInfo.GetText(SP_GETWHOLEPHRASE,SP_GETWHOLEPHRASE,true));
end;
procedure TForm3.SpSharedRecoContext1Hypothesis(ASender: TObject;
StreamNumber: Integer;
StreamPosition: OleVariant;
const Result: ISpeechRecoResult);
begin
Caption := 'I am listening...';
end;
end.
、
THX timo314
編集: は、私は、Delphi 6 Personal Editionの
SAPI 5.1は、 "インポートタイプライブラリ" に記載されていない持っウィンドウ
コンパイル46行目と47行目で「互換性のないタイプのパラメータリストが異なる」というエラーが表示される
SpeechLib_TL例に付属のB.pasは、 "インポート"ディレクトリで作成されたインポートとは異なります。
SpSharedRecoContext1RecognitionとSpSharedRecoContext1Hypothesisのパラメータリストを変更した後、アプリケーションは実行されますが、プロシージャは呼び出されません。プログラムが誰かが話していることに気付かないかのように。
ようこそStackOverflow。どのバージョンのDelphiですか? 「インポートできません」とはどういう意味ですか?あなたのWindows版ではインストールされていませんが、SAPI 5.4をお持ちですか?その場合、5.4は以前のバージョンと下位互換性があります。あなたはどんな問題を抱えていますか?エラーメッセージが表示されますか?あなたの質問を編集してください。私たちがあなたの問題を解決するのに役立つように私たちに提供した情報だけを持っていることを忘れないでください。あなたが私たちに言わなければ、私たちは知ることができません - スクリーンやコードを見ることはできません。 :) –