ubuntu 18.04 python3
You can speak Japanese with OpenJtalk, the following Qiita is easy to understand. Speak Japanese text with OpenJTalk + python
Voice utterances in English introduce espeak and svoxpico.
espeak
Install the environment with the following command.
$sudo apt-get install espeak
Operation check
python
from subprocess import call
call(["espeak","hello world"])
svoxpico
Install the environment with the following command.
sudo apt-get install -y libttspico-utils
Operation check Caution! The file name is module_pico.py, If you create it with another name, it will not work unless you change the # Define path part.
module_pico.py
import os
import subprocess
file_path = os.path.abspath(__file__)
# Define path
speech_wave = file_path.replace('/module_pico.py', '/speech.wav')
def speak(content):
print("[*] SPEAK : {0}".format(content),flush=True)
#subprocess.call('amixer sset Master 90% -q --quiet', shell=True) # big voice
subprocess.call(['pico2wave', '-w={}'.format(speech_wave), content])
subprocess.call('aplay -q --quiet {}'.format(speech_wave), shell=True)
#subprocess.call('amixer sset Master 75% -q --quiet', shell=True) # default voice
if __name__ == '__main__':
speak("I like apple!")
When using it as a module, you can speak in the same folder as follows. You don't have to worry about the file name.
test.py
import module_pico
module_pico.speak("I like apple!")
Recommended Posts