0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

.NETのSpeech.Recognitionをバッチファイルから使う

Posted at

音声認識のエンジンそのものを自作するのはしんどすぎますが、一方で音声認識のソリューションは「ごつすぎる」という特徴もあります。

WordやGoogleDocumentにも音声認識機能がありますが、音声認識単体の機能を取り出すこともできません。そこで.NETフレームワークのSpeech.Recognition APIだけを使ってみましょう。

Speech.Recognition APIもPowerShellから直接呼び出すことができます。ただよくある音声認識ツールと同様に一回でそのターンは終わってしまうので、バッチファイルで無限ループにしましょう。

以下完成形です。

ssr.bat
@echo off
:LOOP
powershell -Command "Add-Type -AssemblyName System.Speech; $r = New-Object System.Speech.Recognition.SpeechRecognitionEngine; $r.LoadGrammar((New-Object System.Speech.Recognition.DictationGrammar)); $r.SetInputToDefaultAudioDevice(); $r.Recognize().Text"
goto LOOP

バッチファイルを起動するとマイクからの入力待ちになります。話しかけて終わるとテキストが吐き出されて次の入力待ちになります。

以下「音声認識の精度はどうでしょう?」と繰り返し聞いてるテスト結果です。

をする認識や制度を低
音声の認識の世論の批判
音声認識の政府を急ぐ
音声認識も歳暮と評

全然ダメですね。今どきのクラウドベースで機械学習で何だったらLLMで「辻褄のあった自然な文章」まで再構築する音声認識に比べるとかなり精度が低いです。

Chromeにも音声認識APIはありますが、あれはChromeからGoogleのクラウドベースのAPIを呼び出してるだけなのでライブラリとしての機能ではありません。オフラインで動作する音声認識ライブラリではvoskなどがありましてそれを使えばもっと精度は高くなります。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?