From 339cf8e1fd192fa4f7ee08b60de2e420c1f39241 Mon Sep 17 00:00:00 2001 From: "ry.yamafuji" Date: Thu, 20 Mar 2025 10:19:41 +0900 Subject: [PATCH] =?UTF-8?q?=E9=9F=B3=E5=A3=B0=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 3 ++- voice/README.md | 45 +++++++++++++++++++++++++++++++++++++ voice/tsx_helloworld.py | 5 +++++ voice/tsx_helloworld_jpn.py | 8 +++++++ 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 voice/README.md create mode 100644 voice/tsx_helloworld.py create mode 100644 voice/tsx_helloworld_jpn.py diff --git a/requirements.txt b/requirements.txt index 4b43f7e..985057b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -matplotlib \ No newline at end of file +matplotlib +pyttsx3 \ No newline at end of file diff --git a/voice/README.md b/voice/README.md new file mode 100644 index 0000000..1a5f380 --- /dev/null +++ b/voice/README.md @@ -0,0 +1,45 @@ +## Install + +```sh +pip install pyttsx3 +``` + +## How To Use + +```sh +import pyttsx3 + +engine = pyttsx3.init() +engine.say("Hello, World!") +engine.runAndWait() +``` + + +日本語音声エンジンのインストール + +```sh +apt install -y open-jtalk +``` + +Open JTalkには、日本語音声ファイルが必要です。 +日本語音声ファイルをダウンロードする。 + +```sh +apt install -y open-jtalk-mecab-naist-jdic hts-voice-nitech-jp-atr503-m001 +``` + +ダウンロードした日本語音声ファイルを以下のパスに配置する + +```sh +/usr/share/hts-voice/nitech-jp-atr503-m001/nitech_jp_atr503_m001.htsvoice +``` + + +```python +import pyttsx3 + +engine = pyttsx3.init() +engine.setProperty('voice', 'japanese') +engine.say("こんにちは、世界!") +engine.runAndWait() +``` diff --git a/voice/tsx_helloworld.py b/voice/tsx_helloworld.py new file mode 100644 index 0000000..437e91d --- /dev/null +++ b/voice/tsx_helloworld.py @@ -0,0 +1,5 @@ +import pyttsx3 + +engine = pyttsx3.init() +engine.say("Hello, World!") +engine.runAndWait() diff --git a/voice/tsx_helloworld_jpn.py b/voice/tsx_helloworld_jpn.py new file mode 100644 index 0000000..472d07b --- /dev/null +++ b/voice/tsx_helloworld_jpn.py @@ -0,0 +1,8 @@ +import pyttsx3 + +engine = pyttsx3.init() +voices = engine.getProperty('voices') +engine.say("こんにちは") +engine.runAndWait() +engine.say("これはテキストの読み上げ機能です") +engine.runAndWait()