文本转音频戏剧 (TTAD) 程序,使用类似播放的脚本。
项目描述
voxtalkz
voxtalkz 是一个开源 python 库,旨在提供将类似播放的脚本转换为半复制音频剧的服务。
入门
先决条件
Python >= 3.6
pip
voxtalkz 需要几个 python 库才能运行:
Google Text To Speach (gTTS)
Pydub (pydub)
这些将使用 pip 自动安装。
安装
pip install voxtalkz
注意:如果pip失败,pip3应该可以工作
测试
编写一个简短的脚本并将其另存为test.script.
# Assign a name to an actor
Susan:british_woman
# Make her say Hello, World!
Susan:Hello, World!
有两个简单的选项可以运行 voxtalks
-
打开命令行并导航到您的文件。
运行脚本。
python3 -m voxtalkz test.script test --debug -
在 python shell 中运行它:
import voxtalks voxtalkz.say(<path/to/test.script>, <output_file_name>, debug=True)
假设一切顺利,您应该会看到一个名为 test.mp3 的文件。使用您喜欢的 mp3 播放程序播放它。(其他文件类型将根据要求提供)
使用 wavnet 语音
而不是python3 -m voxtalkz test.script test --debug, 使用python3 -m voxtalkz test.script test --debug --cloud <my_api_key>(可能不起作用)
或在空闲或脚本中:
python import voxtalks voxtalkz.say(<path/to/test.script>, <output_file_name>, debug=True, cloudKey=<my_api_key>)
将 <my_api_key> 替换为 Google Cloud TextToSpeach API 密钥,(谷歌Google Cloud TextToSpeach API key它以了解如何获得)
这将为您提供比默认默认声音更好的声音,但请记住,wavenet 有不同的声音。查看帮助部分以获取更多信息。
通过 ssml 支持 wavenet 语音的修饰符,带有一个简单的转换脚本,例如:
Susan:real_american_woman
Susan: Hello World! __I really like dirt.__ *Dirt tasts good.*
听起来像:世界你好!我真的很喜欢泥土。 泥土味道不错。
请记住,强调一个词会破坏句子的流畅性,因此以下
Susan:real_american_woman
Susan: I __really__ like dirt.
听起来像我。真的。像泥土。
使用音效
导航到您的主目录(在 C:/Users/Username 的 Windows 上)并创建一个名为.voxtalkz.
导航到该文件夹并创建一个名为soundEffects.
下载 .mp3 或 .wav 音效(其他文件类型将根据要求提供,或根据我的需要提供)并将其放在.voxtalkz/soundEffects/文件夹中,对于本教程,我们假设文件名为footsteps.mp3.
编写一个简短的脚本并将其另存为test2.script.
# Assign a name to an actor
Susan:british_woman
# Make her say Hello, World!
Susan:Hello, World!
Susan:Goodbye, World!
# Add the soud effect
*footsteps
打开命令行并导航到您的文件。运行脚本。
python3 -m voxtalkz test2.script test2 --debug
播放 test2.mp3
添加修饰符
编写一个简短的脚本并将其另存为test3.script.
# Assign a name to an actor
Susan:british_woman
# Make her say Hello, World! as a little girl
Susan:Hello, World!@PITCH=0.3
# Make her say Goodbye, World! as an old woman
Susan:Goodbye, World!@PITCH=-0.3
打开命令行并导航到您的文件。运行脚本。
python3 -m voxtalkz test3.script test3 --debug
播放生成的 test3.mp3。
在 Python 中使用 in 和列表
import voxtalkz
TalkzBox = voxtalkz.voxTalkz('',<outputfilename>)
mylist = [['Susan','british_woman'],['Susan', 'Hello, world!']]
TalkzBox.ListToSound(mylist)
用作 Python 库
复制voxtalkz.py到包含要使用它的 python 文件的文件夹。
将这些代码行添加到您的程序中:
import voxtalkz
TalkzBox = voxtalkz.voxTalkz(<scriptname>,<outputfilename>)
Parsed = TalkzBox.Parse(TalkzBox.file)
OutputSound = TalkzBox.ListToSound(Parsed)
# OutputSound is an instance of pydub.AudioSegment. It can be proccesed with pydub now.
OutputSound.export(filename, format='<.wav, .mp3, and others>')
贡献
任何和所有的帮助将不胜感激!如果可能,将实施任何功能请求。
作者
- Don Flymoor -初始工作- DonFlymoor
执照
这个项目是在 GNUv3 许可证下获得许可的 - 请参阅LICENSE.md文件了解详细信息
用法
Usage: python3 -m voxtalkz [input file, output file]
Converts play-like script to a .mp3 file
Script file must be written in this manner:
#The first time a unknown name is called, instead of making the person talk, the name will be assigned to a person.
Susan:american_woman
#Then the person will "talk"
Susan:Hello, world!
#Comments are allowed!
*soundeffect_without_filename_extension
Effects can be applied by adding an @ symbal the the effect name, like so:
person1:hello, world!@VOLUME=8
A second effect can be applied by using the pipe("|") like so:
person1:Hello, World!@FADE|VOLUME=8
List of all effects:
@FADE | Fade to nothing
@FADE_IN | Fade in from silent
@OVERLAY | Overlays the sound onto what has already been recorded. Use @OVERLAY=VAR1 to START the overlay at the begining of where you assigned @VAR=1
@REPEAT= | Repeat audio segment however many times you specify. e.g. (american_woman:Hello, world!@REPEAT=10) would produce Someone saying "Hello, world!" ten times
@VAR= | Assign a number to a temporary table. Only used with @OVERLAY
@VOLUME= | Set volume change in decibels. A negitive number will reduce the volume
@PITCH= | Set pitch change. e.g. "american_woman:Hello, world!@PITCH=0.3" would make the person sound like a little girl, while "american_woman:Hello, world!@PITCH=-0.3" would sound like an old woman
Wavenet/Cloud voice specific effects:
@SPEAKINGRATE= | number from 0.25 to 4.0, where 1 is normal, 2 is twice as fast, 0.5 if half speed...
List of all normal actors:
indian_man | Clearly speaks
american_woman | Clearly speaks
scottish_woman
russian_woman
drawling_man
danish_woman | Clearly speaks
dutch_woman
au_woman | Clearly speaks
british_woman | Clearly speaks
indian_woman | Clearly speaks
spanish_woman
french_woman
hindu_woman
alien_man
italian_man
phone_woman
korean_man | Clearly speaks
dramatized_woman
silly_man
robot_man
dramitized_girl
bored_teen
happy_girl
boss_lady
young_grandma
spoiled_girl
american_woman
List of all wavenet actors:
"real_australian_woman":["en-AU-Wavenet-A","en-AU"],
"real_australian_man":["en-AU-Wavenet-B","en-AU"],
"real_personal_australian_woman":["en-AU-Wavenet-C","en-AU"],
"real_personal_australian_man":["en-AU-Wavenet-D","en-AU"],
"real_indian_woman":["en-IN-Wavenet-A","en-IN"],
"real_indian_man":["en-IN-Wavenet-B","en-IN"],
"real_personal_indian_woman":["en-IN-Wavenet-C","en-IN"],
"real_personal_indian_man":["en-IN-Wavenet-D","en-IN"],
"real_british_woman":["en-GB-Wavenet-A","en-GB"],
"real_british_man":["en-GB-Wavenet-B","en-GB"],
"real_personal_british_woman":["en-GB-Wavenet-C","en-GB"],
"real_urgent_british_woman":["en-GB-Wavenet-F","en-GB"],
"real_personal_british_man":["en-GB-Wavenet-D","en-GB"],
"real_young_american_man":["en-US-Wavenet-A","en-US"],
"real_middleage_american_man":["en-US-Wavenet-B","en-US"],
"real_american_man":["en-US-Wavenet-B","en-US"],
"real_middleage_american_woman":["en-US-Wavenet-C","en-US"],
"real_american_woman":["en-US-Wavenet-C","en-US"],
"real_middleage_personal_american_man":["en-US-Wavenet-D","en-US"],
"real_middleage_personal_american_woman":["en-US-Wavenet-E","en-US"],
"real_young_personal_american_woman":["en-US-Wavenet-F","en-US"],
"real_distracted_middleage_american_woman":["en-US-Wavenet-G","en-US"],
"real_young_american_woman":["en-US-Wavenet-H","en-US"],
"real_young_personal_american_man":["en-US-Wavenet-I","en-US"],
"real_cocky_american_man":["en-US-Wavenet-J","en-US"]
+ all normal actors
Sound effects must be in the .mp3 or .wav format and placed in /home/user/.voxtalk/soundEffects
To use footsteps.mp3 as a sound effect: put '*footsteps' in your script
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。