rw-generate-audio

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Generate 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

预检查

  1. command -v uv
    must succeed
  2. RUNWAYML_API_SECRET
    must be set, or pass
    --api-key
  1. 执行
    command -v uv
    必须成功
  2. 必须设置
    RUNWAYML_API_SECRET
    环境变量,或通过
    --api-key
    参数传入API密钥

Audio Types

音频类型

TypeDescriptionRequired Args
tts
Text to speech
--text
sfx
Sound effect generation
--text
isolate
Isolate voice from audio
--audio-url
dub
Dub to another language
--audio-url
,
--target-language
sts
Voice conversion
--audio-url
类型描述必填参数
tts
文本转语音
--text
sfx
音效生成
--text
isolate
从音频中分离人声
--audio-url
dub
多语言配音
--audio-url
,
--target-language
sts
语音转换
--audio-url

Parameters

参数说明

ParamDescriptionDefault
--type
Audio type (required): tts, sfx, isolate, dub, sts--
--filename
Output filename (required)--
--text
Text input (for tts and sfx)--
--audio-url
Audio URL or local path (for isolate, dub, sts)--
--voice-id
Voice preset (for tts and sts, e.g. Maya, Noah, Leslie)Maya
--target-language
Language code (for dub, e.g. "es")--
--output-dir
Output directorycwd
--api-key
Runway API keyenv
RUNWAYML_API_SECRET
参数描述默认值
--type
音频类型(必填):tts、sfx、isolate、dub、sts--
--filename
输出文件名(必填)--
--text
文本输入(适用于tts和sfx类型)--
--audio-url
音频URL或本地路径(适用于isolate、dub、sts类型)--
--voice-id
预设语音(适用于tts和sts类型,例如Maya、Noah、Leslie)Maya
--target-language
语言代码(适用于dub类型,例如"es")--
--output-dir
输出目录当前工作目录(cwd)
--api-key
Runway API密钥环境变量
RUNWAYML_API_SECRET

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
  • 脚本会下载生成结果并保存到指定路径
  • 脚本会输出保存文件的完整路径