先人に感謝
キーワード: 音声認識, Google API, Python, SpeechRecognition
Python の URL: http://www.python.org/
インストール手順の詳細は: 別ページで説明している.
コマンドプロンプトを管理者として実行し,次のコマンドを実行.
python -m pip install -U pip setuptools python -m pip install -U jupyterlab jupyter jupyter-console jupytext nteract_on_jupyter spyder
システム Python を使用(インストール操作は不要)
端末で,次のコマンドを実行.
sudo apt -y install python3-dev python3-pip python3-setuptools sudo pip3 uninstall ptyprocess sniffio terminado tornado jupyterlab jupyter jupyter-console jupytext nteract_on_jupyter spyder sudo apt -y install jupyter jupyter-qtconsole spyder3 sudo apt -y install python3-ptyprocess python3-sniffio python3-terminado python3-tornado sudo pip3 install jupyterlab nteract_on_jupyter
※ Windows では「python」,Ubuntu では「sudo python3 -m pip」
python -m pip install -U SpeechRecognition
引き続き,次のコマンドを実行
pip install -U pyaudio
※ 手元に .wav ファイルがないよ,というときは http://www.wavsource.com(インターネットでは,下品な広告が付いている可能性があるので,必要もないのにクリックしないこと) などから入手できる(.wav ファイルをダウンロードするときは、利用条件などを確認すること)
jupyter qtconsole
Python プログラムを動かして,結果を見たい.
Jupyter Qt Console, spyder, PyCharm, PyScripter が便利である. Windows では,スタートメニューの「IDLE (Python ...)」も便利である.
※ 「jupyter qtconsole」を入れたのに,jupyter qtconsole が起動しない という場合には,次の操作で,インストールを行ってから,もう一度試してみる.
※ Windows では「python」,Ubuntu では「sudo python3 -m pip」
python -m pip install -U jupyterlab jupyter jupyter-console jupytext spyder
import os print(os.getcwd())
実行結果例
「Python コンソール」を使う.
※ PyCharmか, Anacondaに入っているspyder を使うのが簡単
次の Python プログラムを実行
「"coincidence.wav" 」のところは,ファイル名を書き換えること.
import speech_recognition r = speech_recognition.Recognizer() with speech_recognition.AudioFile("coincidence.wav") as source: audio = r.record(source) r.recognize_google(audio)
実行結果の例
次の Python プログラムを実行
「"1.wav" 」のところは,ファイル名を書き換えること.
import speech_recognition r = speech_recognition.Recognizer() with speech_recognition.AudioFile("1.wav") as source: audio = r.record(source) r.recognize_google(audio, language='ja-JP')
実行結果の例
本サイトは金子邦彦研究室のWebページです.サイトマップは,サイトマップのページをご覧下さい. 本サイト内の検索は,サイト内検索のページをご利用下さい.
問い合わせ先: 金子邦彦(かねこ くにひこ)