Speech Module

Speech Module

 1 FIRST_TEN = ["one", "two", "three", "four", "five", "six", "seven",
 2              "eight", "nine"]
 3 SECOND_TEN = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen",
 4               "sixteen", "seventeen", "eighteen", "nineteen"]
 5 OTHER_TENS = ["twenty", "thirty", "forty", "fifty", "sixty", "seventy",
 6               "eighty", "ninety"]
 7 HUNDRED = "hundred"
 8
 9
10 def checkio(number):
11     spoken = []
12
13     hundred_bit = number / 100
14
15     if hundred_bit > 0:
16         spoken.append(FIRST_TEN[hundred_bit - 1])
17         spoken.append(HUNDRED)
18
19     remain = number % 100
20
21     if remain >= 10 and remain <= 19:
22         spoken.append(SECOND_TEN[remain % 10])
23     else:
24         decade = remain / 10
25         if decade > 0:
26             spoken.append(OTHER_TENS[decade - 2])
27
28         unit = remain % 10
29         if unit > 0:
30             spoken.append(FIRST_TEN[unit - 1])
31
32     return ‘ ‘.join(spoken)

python有个divmod函数, 即可返回商又可返回余数h, number = divmod(number, 100)

可以如此构造字符串 final_string = "%s%s%s" (hundred_s, decade_s, unit_s)

使用strip去除字符,lstrip, rstrip; rstrip()去除右边空格

Speech Module

时间: 2024-12-16 20:53:01

Speech Module的相关文章

容易使用的读取文本播放器 Text to Speech Maker 2.5

FilmConvert Stand Alone 1.216 MacOSXAutodesk.Smoke.v2015.SP1.MacOSX 1DVDAutodesk Smoke 2015提供更快的效能和更平易近人的价格专 为以Mac计算机作业的小型工作室设计,Smoke 2015专业影音特效和剪辑工具现在具备了 3D追踪.新的Timeline FX工作流程.针对搭载OS X Mavericks操作系统的新版Mac Pro新增硬件支持和系统运作的最佳化,并与Final Cut Pro X提供更佳的互通

自然语言15_Part of Speech Tagging with NLTK

https://www.pythonprogramming.net/part-of-speech-tagging-nltk-tutorial/?completed=/stemming-nltk-tutorial/ One of the more powerful aspects of the NLTK module is the Part of Speech tagging that it can do for you. This means labeling words in a senten

Module Code: CMT307

Cardiff School of Computer Science and InformaticsCoursework Assessment Pro-formaModule Code: CMT307Module Title: Applied Machine LearningAssessment Title: Coursework 1Assessment Number: 1Date Set: Monday, October 28thSubmission Date and Time: Tuesda

csharp:Google TTS API text to speech

? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86

Csharp: speech to text, text to speech in win

? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86

Python学习:模块(module)

为了编写可维护的代码,我们把很多函数分组,分别放到不同的文件里,这样,每个文件包含的代码就相对较少,很多编程语言都采用这种组织代码的方式.在Python中,一个.py文件就称之为一个模块(Module). 为什么使用模块? 和C语言类似: 1.大大提高代码的可维护性: 2.很多功能代码可以复用,可以被第三方引用: 3.不同的模块拥有不同的命名空间,可以避免函数名.变量名冲突. 要是不同的人编写的模块名相同怎么办?为了避免冲突,Python引入了按目录来组织模块的方法,成为包(package).

AttributeError: &#39;module&#39; object has no attribute &#39;dumps&#39;

报错: [[email protected] ~]# ./json.py DATA: [{'a': 'A', 'c': 3.0, 'b': (2, 4)}] Traceback (most recent call last): File "./json.py", line 4, in <module> import json File "/root/json.py", line 8, in <module> data_string = jso

nginx安装报错./configure: error: the http rewrite module requires the pcre library.

nginx编译时报错: ./configure: error: the http rewrite module requires the pcre library. 解决方法: [[email protected] nginx-1.5.9]#  yum install zlib-devel -y

@野兽的Angular Api 学习、翻译及理解 - - angular.module

@野兽的 ng api 学习 -- angular.module angular.module 创建一个全局的可用于检索和注入的Angular模块.所有Angular模块(Angular核心模块或者第三方模块)想要在应用里实现,都需要使用这个注入机制. 格式:angular.module(name,[requires],[configFn]); name :  string  创建的模块名称. [requires]: 字符串的数组  代表该模块依赖的其他模块列表,如果不依赖其他模块,则为空数组.