Text-to-speech (TTS) tool that converts text to audio files (opus or mp3 format).
from pywayne.tts import text_to_speech_output_opus
# Output: test.opus
text_to_speech_output_opus("你好,世界", "test.opus")
Parameters:
text - Text to convertopus_filename - Output .opus filenameuse_say - If True, use macOS 'say' command; otherwise use gTTS (default True)Behavior:
use_say=Truefrom pywayne.tts import text_to_speech_output_mp3
# Output: test.mp3
text_to_speech_output_mp3("你好,世界", "test.mp3")
Parameters:
text - Text to convertmp3_filename - Output .mp3 filenameuse_say - If True, use macOS 'say' command; otherwise use gTTS (default True)Behavior:
use_say=True# Convert text to Opus format (default: macOS uses 'say')
text_to_speech_output_opus "你好,世界" "test.opus"
# Convert text to MP3 format
text_to_speech_output_mp3 "你好,世界" "test.mp3"
# Force use gTTS instead of macOS 'say'
text_to_speech_output_mp3 "你好,世界" "test.mp3" use_say=False
brew install ffmpegsudo apt install ffmpeg or package managerModule automatically detects platform and prompts for ffmpeg installation if missing.
共 1 个版本