pyopenjtalk-plus

0.4.1.post8 · active · verified Fri Apr 17

pyopenjtalk-plus is a Python wrapper for OpenJTalk, a Japanese Text-to-Speech (TTS) system. It enhances the original pyopenjtalk with features like automatic dictionary and voice data downloads, customizable voice presets, and improved phoneme generation. The library is actively maintained, currently at version 0.4.1.post8, with frequent minor updates addressing bug fixes and improvements.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to generate phonemes and audio from Japanese text using pyopenjtalk-plus. The library automatically handles the download of OpenJTalk dictionaries and voice data on first use, simplifying setup. Audio output is a NumPy array, requiring external libraries like `soundfile` or `pyaudio` for saving or playback.

import pyopenjtalk_plus
import os

# Set a dummy variable for demonstration if needed, otherwise rely on default behavior.
# pyopenjtalk-plus typically manages data download automatically.
# os.environ['OPENJTALK_DATA_DIR'] = '/path/to/openjtalk_data' # Optional, for custom data path

text = "こんにちは、世界。私はAIです。"

# 1. Get phonemes
phonemes = pyopenjtalk_plus.make_phoneme(text)
print(f"Phonemes: {phonemes}")

# 2. Generate audio (returns sample rate and numpy array of audio data)
# The library will attempt to download necessary dictionaries and voice data on first run.
try:
    sr, y = pyopenjtalk_plus.make_audio(text)
    print(f"Audio generated successfully: Sample Rate={sr}, Data shape={y.shape}")

    # To save the audio to a file, you'd typically use a library like soundfile:
    # import soundfile as sf
    # sf.write("output.wav", y, sr)
    # print("Audio saved to output.wav")

except Exception as e:
    print(f"Error generating audio: {e}")
    print("Ensure OpenJTalk dictionaries and voice files are accessible. \n"\
          "The library usually downloads them automatically, but network or permissions issues can cause failures.")

view raw JSON →