rw-generate-audio
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGenerate Audio
生成音频
Generate audio directly using the Runway API. Supports text-to-speech, sound effects, voice isolation, dubbing, and speech-to-speech voice conversion.
IMPORTANT: Run scripts from the user's working directory so output files are saved where the user expects.
直接使用Runway API生成音频。支持文本转语音(TTS)、音效生成、人声分离、配音以及语音转语音(语音转换)功能。
重要提示: 从用户的工作目录运行脚本,以便输出文件保存到用户预期的位置。
Usage
使用方法
bash
uv run scripts/generate_audio.py --type tts --text "Hello world" --filename "greeting.mp3" [--voice-id ID] [--api-key KEY]bash
uv run scripts/generate_audio.py --type tts --text "Hello world" --filename "greeting.mp3" [--voice-id ID] [--api-key KEY]Preflight
预检查
- must succeed
command -v uv - must be set, or pass
RUNWAYML_API_SECRET--api-key
- 执行必须成功
command -v uv - 必须设置环境变量,或通过
RUNWAYML_API_SECRET参数传入API密钥--api-key
Audio Types
音频类型
| Type | Description | Required Args |
|---|---|---|
| Text to speech | |
| Sound effect generation | |
| Isolate voice from audio | |
| Dub to another language | |
| Voice conversion | |
| 类型 | 描述 | 必填参数 |
|---|---|---|
| 文本转语音 | |
| 音效生成 | |
| 从音频中分离人声 | |
| 多语言配音 | |
| 语音转换 | |
Parameters
参数说明
| Param | Description | Default |
|---|---|---|
| Audio type (required): tts, sfx, isolate, dub, sts | -- |
| Output filename (required) | -- |
| Text input (for tts and sfx) | -- |
| Audio URL or local path (for isolate, dub, sts) | -- |
| Voice preset (for tts and sts, e.g. Maya, Noah, Leslie) | Maya |
| Language code (for dub, e.g. "es") | -- |
| Output directory | cwd |
| Runway API key | env |
| 参数 | 描述 | 默认值 |
|---|---|---|
| 音频类型(必填):tts、sfx、isolate、dub、sts | -- |
| 输出文件名(必填) | -- |
| 文本输入(适用于tts和sfx类型) | -- |
| 音频URL或本地路径(适用于isolate、dub、sts类型) | -- |
| 预设语音(适用于tts和sts类型,例如Maya、Noah、Leslie) | Maya |
| 语言代码(适用于dub类型,例如"es") | -- |
| 输出目录 | 当前工作目录(cwd) |
| Runway API密钥 | 环境变量 |
Examples
示例
Text-to-speech:
bash
uv run scripts/generate_audio.py --type tts --text "Welcome to our product showcase" --filename "voiceover.mp3"Sound effect:
bash
uv run scripts/generate_audio.py --type sfx --text "Thunder rolling across a stormy sky" --filename "thunder.mp3"Voice isolation:
bash
uv run scripts/generate_audio.py --type isolate --audio-url "noisy-recording.mp3" --filename "clean-voice.mp3"Speech-to-speech (voice conversion):
bash
uv run scripts/generate_audio.py --type sts --audio-url "recording.mp3" --voice-id Noah --filename "converted.mp3"Dubbing:
bash
uv run scripts/generate_audio.py --type dub --audio-url "english-narration.mp3" --target-language es --filename "spanish-dub.mp3"文本转语音:
bash
uv run scripts/generate_audio.py --type tts --text "Welcome to our product showcase" --filename "voiceover.mp3"音效生成:
bash
uv run scripts/generate_audio.py --type sfx --text "Thunder rolling across a stormy sky" --filename "thunder.mp3"人声分离:
bash
uv run scripts/generate_audio.py --type isolate --audio-url "noisy-recording.mp3" --filename "clean-voice.mp3"语音转语音(语音转换):
bash
uv run scripts/generate_audio.py --type sts --audio-url "recording.mp3" --voice-id Noah --filename "converted.mp3"多语言配音:
bash
uv run scripts/generate_audio.py --type dub --audio-url "english-narration.mp3" --target-language es --filename "spanish-dub.mp3"Output
输出
- The script downloads the result and saves it to the specified path
- Script outputs the full path to the saved file
- 脚本会下载生成结果并保存到指定路径
- 脚本会输出保存文件的完整路径