● URL(再)変更のお知らせ
2019/02 猫屋敷サーバ neko.ne.jpが復旧かも?なので
ネットオウル株式会社が運営するスターサーバーフリー
http://freewing.starfree.jp/
から
http://www.neko.ne.jp/~freewing/
に戻しました。。。。
・2017/11/30
Raspberry Pi 3に Google Cloud Speech APIを入れて各国の言語で音声認識をする方法
(ラズパイに Google Cloud Speech APIを設定する方法(Node.js言語編))
Tags: [Raspberry Pi], [電子工作]
● Raspberry Pi 3 Model Bを遂に購入
Raspberry Pi3 Model B RPI2 RPI3
大人気の CPUボードの Raspberry Piに WiFiと Bluetoothが搭載されたモデルが新発売となりました。
以前から Raspberry Pi 2を買おうかどうか迷っていましたが、Raspberry Pi 3 Model Bの発売を機に購入を決意してラズベリアンになる事にしました。
※ ラズパイの OS Raspbianはバージョンが上がる毎に過去の版と OSの内部の作りが変わり、過去に書かれた製作記事(例えば Raspbian Wheezyの時代の記事)がそのままではエラーが出たりして動かない事が有ります。
※ 当方のホームページのラズパイ記事は全て Raspberry Pi 3 Model Bと Raspbian Jessieの組み合わせで動作確認をしております。
(ただし、将来的に新しい Raspbian OSが出た場合に、当方の Raspbian Jessieを基にした内容がそのままでは動かない可能性が有ります。)
※ 2017/08/16から Raspbian OSは Raspbian Jessieから Raspbian Stretchに変わりました。
Download Raspbian for Raspberry Pi
ちなみに、歴代のバージョンと名称は
Debian | コードネーム | 年月 | 備考 |
Debian 9 | Stretch | 2017/08/16~ | |
Debian 8 | Jessie | 2015~ | 2016/02からラズパイ3対応 |
Debian 7 | Wheezy | 2013~2016 | |
Debian 6.0 | Squeeze | 2011~2014 | |
Debian GNU/Linux 5.0 | Lenny | 2009~2012 | |
● Raspberry Pi 3で Cloud Speech API クライアント ライブラリで音声認識
Cloud Speech API クライアント ライブラリ
Google Cloud Speech API Node.js Client
下記は Node.jsクライアントの古い場所(もう無い)
Samples for the Google Cloud Speech API Node.js Client have moved to github.com/googleapis/nodejs-speech/tree/master/samples/.
●
$ nodejs -v
v4.8.2
Node.js v8.x
# Node.js v8.x
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get -y install nodejs
pi@raspberrypi:~/java-docs-samples/speech/cloud-client $ node -v
v8.9.1
pi@raspberrypi:~/java-docs-samples/speech/cloud-client $ nodejs -v
v8.9.1
pi@raspberrypi:~/java-docs-samples/speech/cloud-client $ npm -v
5.5.1
●
cd
mkdir node
cd node/
npm install --save @google-cloud/speech
●
サービス アカウント キーの作成
App Engine
JSON
export GOOGLE_APPLICATION_CREDENTIALS='/home/pi/hogehoge-xxxxxxxxxxxx.json'
●
# Google Cloud Speech API: Node.js Client
Node.js client for Google Cloud Speech: Speech to text conversion powered by machine learning. https://cloud.google.com/speech/
https://github.com/googleapis/nodejs-speech
git clone https://github.com/googleapis/nodejs-speech.git
cd nodejs-speech
# Google Cloud Speech API: Node.js Samples
cd samples
ls -l
pi@raspberrypi:~/node/nodejs-speech/samples $ ls -l
-rw-r--r-- 1 pi pi 654 Dec 3 06:39 package.json
-rw-r--r-- 1 pi pi 1795 Dec 3 06:39 quickstart.js
-rw-r--r-- 1 pi pi 3755 Dec 3 06:39 README.md
-rw-r--r-- 1 pi pi 16780 Dec 3 06:39 recognize.js
drwxr-xr-x 2 pi pi 4096 Dec 3 06:39 resources
drwxr-xr-x 2 pi pi 4096 Dec 3 06:39 system-test
npm install
●
pi@raspberrypi:~/node/nodejs-speech/samples $ node recognize.js --help
recognize.js <command>
Commands:
recognize.js sync <filename> Detects speech in a local audio file.
recognize.js sync-gcs <gcsUri> Detects speech in an audio file located in a Google Cloud Storage bucket.
recognize.js sync-words <filename> Detects speech in a local audio file with word time offset.
recognize.js async <filename> Creates a job to detect speech in a local audio file, and waits for the job to
complete.
recognize.js async-gcs <gcsUri> Creates a job to detect speech in an audio file located in a Google Cloud
Storage bucket, and waits for the job to complete.
recognize.js async-gcs-words <gcsUri> Creates a job to detect speech with word time offset in an audio file located
in a Google Cloud Storage bucket, and waits for the job to complete.
recognize.js stream <filename> Detects speech in a local audio file by streaming it to the Speech API.
recognize.js listen Detects speech in a microphone input stream. This command requires that you
have SoX installed and available in your $PATH. See
https://www.npmjs.com/package/node-record-lpcm16#dependencies
Options:
--version Show version number [boolean]
--encoding, -e [string] [default: "LINEAR16"]
--sampleRateHertz, -r [number] [default: 16000]
--languageCode, -l [string] [default: "en-US"]
--help Show help [boolean]
Examples:
node recognize.js sync ./resources/audio.raw -e LINEAR16 -r 16000
node recognize.js async-gcs gs://gcs-test-data/vr.flac -e FLAC -r 16000
node recognize.js stream ./resources/audio.raw -e LINEAR16 -r 16000
node recognize.js listen
For more information, see https://cloud.google.com/speech/docs
● Gitのサンプル音声の音声認識
pi@raspberrypi:~/node/nodejs-speech/samples $ node recognize.js sync ./resources/audio.raw
Transcription: how old is the Brooklyn Bridge
pi@raspberrypi:~/node/nodejs-speech/samples $ node recognize.js sync ./resources/audio2.raw
Transcription: the rain in Spain stays mainly on the plain
pi@raspberrypi:~/node/nodejs-speech/samples $ node recognize.js sync ./resources/quit.raw
Transcription: quit
100%の認識率
●
$ node recognize.js --version
0.0.1
● FLAC形式の音声を認識
node recognize.js sync ~/recorded.flac -e FLAC -l ja-JP
pi@raspberrypi:~/node/nodejs-speech/samples $ node recognize.js sync ~/recorded.flac -e FLAC -l ja-JP
Transcription: こんにちは音声認識
● listenは動かず
node recognize.js listen -l ja-JP
pi@raspberrypi:~/node/nodejs-speech/samples $ node recognize.js listen -l ja-JP
Listening, press Ctrl+C to stop.
events.js:183
throw er; // Unhandled 'error' event
^
Error: spawn rec ENOENT
at _errnoException (util.js:1024:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
at onErrorNT (internal/child_process.js:372:16)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
at Function.Module.runMain (module.js:678:11)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
●音声認識
女性声優・雛乃木まや公式サイト 〜ナレーションやキャラボイスを依頼できます〜
“留守番電話のアナウンス音声”のフリー女性音声ボイスを無料でお使い頂けます。
2016.10.05 クレジットフリー・無料音声のダウンロード
wget http://hinanogimaya.com/wp-content/uploads/2016/10/voice-odenwa-arigatougozaimasu-taihenmoushiwake.wav
pi@raspberrypi:~/node/nodejs-speech/samples $ node recognize.js sync ./voice-odenwa-arigatougozaimasu-taihenmoushiwake.wav -l ja-JP
ERROR: { Error: sample_rate_hertz (16000) in RecognitionConfig must either be omitted or match the value in the WAV header ( 44100).
at /home/pi/node/nodejs-speech/samples/node_modules/grpc/src/client.js:554:15
code: 3,
metadata: Metadata { _internal_repr: {} },
note: 'Exception occurred in retry method that was not classified as transient' }
pi@raspberrypi:~/node/nodejs-speech/samples $ node recognize.js sync ./voice-odenwa-arigatougozaimasu-taihenmoushiwake.wav -l ja-JP -r 44100
Transcription: お電話ありがとうございます大変申し訳ありませんが本日の営業は終了させていただきましたまたおかけ直しいただきますようお願い申し上げます
100%の認識率
●音声認識
総務省|平成27年版 情報通信白書|PDF版
http://www.soumu.go.jp/johotsusintokei/whitepaper/ja/h27/pdf/index.html
平成27年版情報通信白書 特集テーマ 「ICTの過去・現在・未来」PDF(481KB)
http://www.soumu.go.jp/johotsusintokei/whitepaper/ja/h27/pdf/27dounyu.pdf
本年2015年は1985年の通信自由化から30周年の節目の年であり、ICT産業の発展経緯や産業構造の変遷、これまでの通信政策とその効果などICTの過去への関心が高まっている。
それと同時に、2020年東京オリンピック・パラリンピック競技大会の開催決定を一つの契機として、国民の未来への関心も高まっている。
人口急減・超高齢化への対応や地方創生といった我が国の将来課題に対し、社会全体のICT化を通じてどのように解決を図っていくかに注目が集まっている。新興国市場の急速な拡大を見据えた我が国ICT産業の国際展開戦略も引き続き重要課題である。
の最初の文章を音声にして認識にさせました。
Sound of Text
voice1.mp3 (24kHz)
を 16kHzの WAV形式に変換
voice1.wav
Sound of Text
pi@raspberrypi:~/node/nodejs-speech/samples $ node recognize.js sync ./voice1.wav -l ja-JP
Transcription: 本年2015年は1985年の通信自由化から30周年の節目の年であり ict 産業の発展経緯や産業構造の変遷これまでの通信政策とその効果など ict の過去への関心が高まっている
100%の認識率
Windows SpeechApp11 Microsoft Speech Platform 11用の Text-to-Speech
・2012/04/03
日本語や中国語等の音声合成(TTS)を無料で使う方法
Microsoft Speech Platform 11 Server Runtimeのインストール方法 多言語対応の Text to Speech
ja-JP Haruka
haruka.wav
ja-JP Haruka
pi@raspberrypi:~/node/nodejs-speech/samples $ node recognize.js sync ./haruka.wav -l ja-JP
Transcription: 本年2015年は1985年の通信自由化から30周年の節目の年であり ict 産業の発展経緯や産業構造の変遷これまでの通信政策とその効果など ict の過去への関心が高まっている
100%の認識率
Tags: [Raspberry Pi], [電子工作]
●関連するコンテンツ(この記事を読んだ人は、次の記事も読んでいます)
Raspberry Pi 3系のトラブルであるある第一位の電源トラブル、低電圧警報に関する情報のまとめ
ラズパイ3B系での低電圧警報に関する情報まとめ、コマンドラインやログファイルから低電圧を検知する方法
Raspberry Piで CPUの脆弱性 Spectreと Meltdownの脆弱性をチェックする方法
ラズパイで 2018年初頭に大騒ぎになったスペクターとメルトダウンの CPUの脆弱性をチェックする方法
Raspberry Pi Zero Wを海外通販の Pimoroni等での購入方法、購入出来る通販ショップ一覧まとめ
ラズパイゼロW ワイヤレスモデルを海外通販でサクッと簡単に個人輸入で入手。技適通過でも国内販売は常に品切れ
Raspberry Pi 3で安定して使える相性の無い最適な microSDカードの種類のまとめ
ラズパイ3で安定して使える microSDカードを購入する Teamと SanDiskは絶対に買わない
Raspberry Pi 3 Model Bに専用カメラモジュール RaspiCamを接続する方法
ラズパイに専用カメラモジュールを接続して Raspbianで写真の静止画撮影や動画を録画する方法
Raspberry Pi 3の Linuxコンソール上で使用する各種コマンドまとめ
ラズパイの Raspbian OSのコマンドラインで使用する便利コマンド、負荷試験や CPUシリアル番号の確認方法等も
Raspberry Pi 3公式フォーラムの FAQの内容の日本語訳
ラズパイ公式フォーラムの「The Raspberry Pi 3 Model B Q&A thread」の日本語訳
Raspberry Pi 3で GPIO端子の I2C機能を有効化する方法
ラズパイ3の GPIO端子の I2C機能を有効にして各種センサーを繋げる方法まとめ
大人気の CPUボード、Raspberry Pi 3 Model Bで作ってみよう
Raspberry Piの開発環境の構築やタッチパネル付き液晶ディスプレイや各種センサーの使い方まとめ
Raspberry Pi関連はこちらへまとめました
下記以外にも多数のラズパイ関係の記事が有ります。
(I2C制御、GPIO制御、1-Wire制御、シリアル通信、日本語音声合成、日本語音声認識、中国語音声合成、MeCab 形態素解析エンジン、赤外線リモコン制御、秋月 I2C液晶モジュール、KeDei 3.5インチ液晶、HDMI 5インチ液晶、NFCカードリーダ、コマンドライン操作方法等)
Espressif ESP8266 Arduino互換でスケッチが使える ESP-12Eモジュール基板
Espressif ESP8266 ESP-12-E NodeMCU V1 ESP12 CP2102
BangGood通販はドローン以外にも面白い商品がまだまだ有った(電子工作編)
レーザー彫刻機、カラー液晶の DIYオシロ、Arduinoや Raspberry Pi用の小型カラー液晶
[HOME]
|
[BACK]
リンクフリー(連絡不要、ただしトップページ以外は Web構成の変更で移動する場合があります)
Copyright (c)
2017 FREE WING,Y.Sakamoto
Powered by 猫屋敷工房 & HTML Generator
http://www.neko.ne.jp/~freewing/raspberry_pi/raspberry_pi_google_cloud_speech_api_stt_nodejs/