[PYTHON] Make Raspberry Pi speak Japanese using OpenJtalk

What you can do with this article

-Installed on OpenJtalk's Raspberry Pi • The actual sound output "Hello"

Operating environment

・ Raspberry Pi3 model B ・ OS: Raspbian

Premise

・ Can be operated with Raspberry Pi ssh connection or can be operated with display ・ Japanese input is possible

Install OpenJtalk

I installed it by referring to this article.

First, do the following

sudo apt-get update #Update
sudo apt-get install open-jtalk #Installation

Then also install the recommended packages.

sudo apt-get install open-jtalk-mecab-naist-jdic hts-voice-nitech-jp-atr503-m00

test

Now you can output audio! OpenJtalk is in the order of creating a Japanese audio file and then playing it. First, create an audio file below.

echo "Hello" | open_jtalk -x /var/lib/mecab/dic/open-jtalk/naist-jdic -m /usr/share/hts-voice/nitech-jp-atr503-m001/nitech_jp_atr503_m001.htsvoice -ow ~/ojtalk.wav

You should now have an audio file called ojtalk.wav in the same directory. Let's play next.

aplay ~/ojtalk.wav

"Hello" Was output?

Opinion of option

-x dictionary to use -m Which voice to use (male or female, etc.) -ow specify output file

When there is a lot of noise

By the way, if it is a 3.5mm analog output, noise may be added and it may not sound good. (I was ...) In that case, try connecting to the display with HDMI and outputting from the display. The noise, probably due to the circuit, disappears.

Output without saving the audio file

This time, I created an audio file and then output it, but if you feel a little uncomfortable that the audio file is saved every time you speak, you can do it without creating an audio file below.

echo "Hello" | open_jtalk -x /var/lib/mecab/dic/open-jtalk/naist-jdic -m /usr/share/hts-voice/nitech-jp-atr503-m001/nitech_jp_atr503_m001.htsvoice -ow /dev/stdout | aplay --quiet

Download female voice

Use the MMDAgent package.

First, execute the following to download

wget https://sourceforge.net/projects/mmdagent/files/MMDAgent_Example/MMDAgent_Example-1.7/MMDAgent_Example-1.7.zip

Then unzip the zip

unzip ./MMDAgent_Example-1.7.zip

And mei-chan's voice folder in the folder Copy it under the directory / usr / share / hts-voice /.

sudo cp -r ./MMDAgent_Example-1.7/Voice/mei/ /usr/share/hts-voice/

If you change the acoustic model to this, it will be a female voice. Optional -m acoustic model It is the part corresponding to.

echo "Hello"|open_jtalk -x /var/lib/mecab/dic/open-jtalk/naist-jdic -m /usr/share/hts-voice/mei/mei_normal.htsvoice -ow ~/ojtalk.wav
aplay ~/ojtalk.wav

I think this is a female voice.

Summary

This time, we have delivered the installation of OpenJtalk and its test. Next, I would like to create a program that talks about the information obtained by API and what was web scraped! Then!

Recommended Posts

Make Raspberry Pi speak Japanese using OpenJtalk
Indoor monitoring using Raspberry Pi
Get the weather using the API and let the Raspberry Pi speak!
Try using ArUco on Raspberry Pi
Speak Japanese text with OpenJTalk + python
Using a webcam with Raspberry Pi
Make a simple CO2 incubator using Raspberry PI and CO2 sensor (MH-Z14A)
Detect "brightness" using python on Raspberry Pi 3!
Run servomotor on Raspberry Pi 3 using python
Make a wash-drying timer with a Raspberry Pi
Detect temperature using python on Raspberry Pi 3!
Detect slide switches using python on Raspberry Pi 3!
Try using a QR code on a Raspberry Pi
Detect magnet switches using python on Raspberry Pi 3!
Automatic launch of Raspberry Pi programs using Systemd
Send data from Raspberry Pi using AWS IOT
Raspberry Pi backup
Make DHT11 available on Raspberry Pi + python (memo)
Sound the buzzer using python on Raspberry Pi 3!
Create a visitor notification system using Raspberry Pi
Connect your Raspberry Pi to your smartphone using Blynk
Build an OpenCV4 environment on Raspberry Pi using Poetry
Create a color sensor using a Raspberry Pi and a camera
Using the digital illuminance sensor TSL2561 with Raspberry Pi
Monitor temperature using Raspberry Pi + Alibaba cloud IoT platform
Try using the temperature sensor (LM75B) on the Raspberry Pi.
Make an umbrella reminder with Raspberry Pi Zero W
Output to "7-segment LED" using python on Raspberry Pi 3!
What is Raspberry Pi?
GPGPU with Raspberry Pi
pigpio on Raspberry pi
Raspberry Pi video camera
Raspberry Pi Bad Knowledge
Let's do Raspberry Pi?
Speaking Japanese with OpenJtalk
Make Japanese into Romaji
I tried to make a motion detection surveillance camera with OpenCV using a WEB camera with Raspberry Pi
DigitalSignage with Raspberry Pi
Raspberry Pi 4 setup memo
Cython on Raspberry Pi
Raspberry Pi system monitoring
OpenJTalk on Windows10 (Speak Japanese with Python from environment construction)
Detect "temperature (using A / D converter)" using python on Raspberry Pi 3!
Access google spreadsheet using python on raspberry pi (for myself)
Make an air conditioner integrated PC "airpi" with Raspberry Pi 3!
I tried using the DS18B20 temperature sensor with Raspberry Pi
I tried to automate [a certain task] using Raspberry Pi
Check! Let's develop Raspberry Pi Zero remotely-Try using Arafruit WebIDE
How to get temperature from switchBot thermo-hygrometer using raspberry Pi
Construction of Cortex-M development environment for TOPPERS using Raspberry Pi
How to upload a file to Cloud Storage using Python [Make a fixed point camera with Raspberry PI # 1]