用python开发alexa技能的ssml构建器

ssml-builder的Python项目详细描述


SSML生成器

安装

pip install ssml-builder

用法

  • 创建语音对象
from ssml_builder.core import Speech

speech = Speech()
  • 添加文本
speech.add_text('sample text')
  • 生成SSML
speech.speak()

功能

  • 此包支持以下ssml标记。
    • 说“u”为
    • 韵律
    • sub
    • 语言
    • 语音
    • 暂停
    • 低语
    • 音频
    • 强调
    • p

标记示例

表示为

speech = Speech()
speech.say_as(value='hello', interpret_as='spell-out')
speech.speak()
# <speak><say-as interpret-as="spell-out">hello</say-as><say-as interpret-as="spell-out">hello</say-as></speak>

韵律
speech = Speech()
speech.prosody(value="sample sentence", rate='70%', pitch='+50%', volume='x-soft')
speech.speak()
# <speak><prosody rate="70%" pitch="+50%" volume="x-soft">sample sentence</prosody></speak>

sub

speech = Speech()
speech.sub(value="Al", alias="aluminum")
speech.speak()
# <speak><sub alias="aluminum">Al</sub></speak>

语言

speech = Speech()
speech.lang(value="Paris", lang="fr-FR")
speech.speak()
# <speak><speak><lang xml:lang="fr-FR">Paris</lang></speak>

语音

speech = Speech()
speech.voice(value="I am not a real human.", name="Kendra")
speech.speak()
# <speak><voice name="Kendra">I am not a real human.</voice></speak>

暂停

speech = Speech()
speech.add_text("There is a three second pause here ")
speech.pause(time="3s")
speech.add_text("then the speech continues.")
speech.speak()
# <speak>There is a three second pause here <break time="3s"/>then the speech continues.</speak>

低语

speech = Speech()
speech.whisper("I am not a real human.")
speech.speak()
# <speak><amazon:effect name="whispered">I am not a real human.</amazon:effect></speak>

音频

speech = Speech()
speech.audio('soundbank://soundlibrary/transportation/amzn_sfx_car_accelerate_01')
speech.speak()
# <speak><audio src="soundbank://soundlibrary/transportation/amzn_sfx_car_accelerate_01" /></speak>

强调

speech = Speech()
speech.add_text('I already told you I ')
speech.emphasis('really like', 'strong')
speech.add_text(' that person')
speech.speak()
# <speak>I already told you I <emphasis level="strong">really like</emphasis> that person</speak>

p

speech = Speech()
speech.p("This is the first paragraph. There should be a pause after this text is spoken.")
speech.p("This is the second paragraph.")
# <speak><p>This is the first paragraph. There should be a pause after this text is spoken.</p><p>This is the second paragraph.</p></speak>

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java实现双锁并发队列   java如何更改SpringWS 2.4.4版或更高版本中maxOccurs的默认限制?   java Selenium RC如何处理动态行?   java何时引入Javac StringBuilder/StringBuffer优化?   java mediaplayer在R.raw Android上失败   java JPA2:不区分大小写,就像在任何地方匹配一样   如何从JDK15中提取java预览类文件?   java与mySQL删除查询不一致   从Shutdownow()返回的java列表<Runnable>无法转换为提交的Runnable   java如何从回调接口获取对象值?   java如何获得视图的高度,在xml中可见性和高度定义为wrap_内容?   postgresql Mybatis在启动时遇到“由以下原因引起:java.net.UnknownHostException:localhost”,为什么?   带有实例调用的方法调用的java intellij格式化程序换行   由于特定的第三方库,java Proguard产生运行时错误   动画JAVA JPanel同时滑出和滑入