やってみた。
情報源
trans --help
Audio options: -p, -play Listen to the translation. -speak Listen to the original text. -n VOICE, -narrator VOICE Specify the narrator, and listen to the translation. -player PROGRAM Specify the audio player to use, and listen to the translation. -no-play Do not listen to the translation. -no-translate Do not translate anything when using -speak. -download-audio Download the audio to the current directory. -download-audio-as FILENAME Download the audio to the specified file.
発話
trans -speak 'こんにちは'
trans -sp 'こんにちは'
ファイル出力
ファイル名を話したテキストと同じにする。
TEXT="こんにちは" WAV="$TEXT.mp3" trans -download-audio-as "$WAV" "$TEXT"
ファイル名を日時にする。
TEXT="こんにちは" WAV="$(date +"%Y%m%d%H%M%S").mp3" trans -download-audio-as "$WAV" "$TEXT"
ファイルを再生する。
mplayer $WAV
声色(変更できなかった)
-n
で声色を変更できるらしいがダメだった。声の名前はこちらを参照した。
ja-JP-Standard-A ja-JP-Standard-B ja-JP-Standard-C ja-JP-Standard-D ja-JP-Wavenet-A ja-JP-Wavenet-B ja-JP-Wavenet-C ja-JP-Wavenet-D
trans -speak -n ja-JP-Standard-C 'こんにちは' trans -speak -n WaveNet 'こんにちは' trans -speak -n Standard-C 'こんにちは' trans -speak -n C 'こんにちは' trans -speak -l ja-JP -n ja-JP-Standard-C 'こんにちは' trans -speak -l 'ja-JP' -n 'ja-JP-Standard-C' 'こんにちは' trans -speak -l 'ja-JP' -s 'ja-JP' -t 'ja-JP' -n 'ja-JP-Standard-C' 'こんにちは' trans -speak -l 'ja-JP' -s 'ja-JP' -t 'ja-JP' -narrator 'ja-JP-Standard-C' 'こんにちは'
ちなみに以下サイトでWebAPI版のJSONをみてみると以下。
{ "audioConfig": { "audioEncoding": "LINEAR16", "pitch": 0, "speakingRate": 1 }, "input": { "text": "Google Cloud Text-to-Speech enables developers to synthesize natural-sounding speech with 100+ voices, available in multiple languages and variants. It applies DeepMind’s groundbreaking research in WaveNet and Google’s powerful neural networks to deliver the highest fidelity possible. As an easy-to-use API, you can create lifelike interactions with your users, across many applications and devices." }, "voice": { "languageCode": "en-US", "name": "en-US-Wavenet-D" } }
ググった。
なんと男女指定しかできない。しかも試したところ同じ女性の声しか出ない。ダメじゃん。
trans -speak -n m 'こんにちは' trans -speak -n f 'こんにちは'
女 | 男 |
---|---|
jane , oksana , alyss , omazh |
zahar , ermil |
感情も指定できる。
短 | 長 |
---|---|
g |
good |
n |
neutral |
e |
evil |
ドキュメントの通りに実行したがエラーになった。
trans -e yandex "Ничего, были бы кости, а мясо будет" -sp -n jane,evil
[ERROR] Oops! Something went wrong and I can't translate it for you :(
対象環境
- Raspbierry pi 4 Model B
- Raspberry Pi OS buster 10.0 2020-08-20 ※
- bash 5.0.3(1)-release
$ uname -a Linux raspberrypi 5.4.83-v7l+ #1379 SMP Mon Dec 14 13:11:54 GMT 2020 armv7l GNU/Linux