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的更多相关文章

  1. Check iO:初学Python

    The end of other For language training our Robots want to learn about suffixes. In this task, you ar ...

  2. [官网]Windows modules

    Windows modules https://docs.ansible.com/ansible/latest/modules/list_of_windows_modules.html win_acl ...

  3. 百度语音+react+loopback实现语音合成返回播放

    1.在百度语音中创建自己的项目,需要拿到APP_ID.API_KEY.SECRET_KEY. 2.loopback端提供接口服务,在./boot目录下新建root.js文件,编写不依赖模型的自定义接口 ...

  4. 【Python CheckiO 题解】SP

    题目描述 [Speech Module]:输入一个数字,将其转换成英文表达形式,字符串中的所有单词必须以一个空格字符分隔. [输入]:一个数字(int) [输出]:代表数字的英文字符串(str) [前 ...

  5. Understanding C++ Modules In C++20 (1)

    Compiling evironment: linux (ubuntu 16.04)+ gcc-10.2. The Post will clarify and discuss what modules ...

  6. 自然语言15_Part of Speech Tagging with NLTK

    https://www.pythonprogramming.net/part-of-speech-tagging-nltk-tutorial/?completed=/stemming-nltk-tut ...

  7. Text Prompted Remote Speaker Authentication : Joint Speech and Speaker Recognition/Verification System :: Major Project ::: Introduction

    转载自:http://ganeshtiwaridotcomdotnp.blogspot.com/2010/12/text-prompted-remote-speaker.html Biometrics ...

  8. 论文翻译:2020_A Recursive Network with Dynamic Attention for Monaural Speech Enhancement

    论文地址:基于动态注意的递归网络单耳语音增强 论文代码:https://github.com/Andong-Li-speech/DARCN 引用格式:Li, A., Zheng, C., Fan, C ...

  9. 论文翻译:2022_PACDNN: A phase-aware composite deep neural network for speech enhancement

    论文地址:PACDNN:一种用于语音增强的相位感知复合深度神经网络 引用格式:Hasannezhad M,Yu H,Zhu W P,et al. PACDNN: A phase-aware compo ...

随机推荐

  1. jquery+ajax分页

    先看效果图:

  2. scriptol图像处理算法

    神奇的图像处理算法   相似图片搜索是利用数学算法,进行高难度图像处理的一个例子.事实上,图像处理的数学算法,已经发展到令人叹为观止的地步. Scriptol列出了几种神奇的图像处理算法,让我们一起来 ...

  3. Linux企业级项目实践之网络爬虫(18)——队列处理

    所有的URL都接受管理,并在此进行流动.URL从管理模块的存储空间开始,一直到最后输出给磁盘上的URL索引,都由此部分调度.首先,给出URL调度的一般过程,如图所示.其流程的各个具体操作,后面详述.要 ...

  4. JVM基础和调优(一)

    最近的项目中,出现了内存和性能的问题,需要优化,所以趁着这个机会,把自己关于java虚拟机的东整理一下,不对的地方,欢迎指出. 数据类型,因为在java的优化的过程中,检测到的数据类型一般比较的基础, ...

  5. paip.索引优化---sql distict—order by 法

    paip.索引优化---sql distict—order by 法 作者Attilax ,  EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http://blog ...

  6. hdu 4756 Install Air Conditioning

    非正规做法,一个一个的暴,减一下枝,还得采用sort,qsort居然过不了…… #include <cstdio> #include <cmath> #include < ...

  7. Android中Service类onStartCommand

    Android开发的过程中,每次调用startService(Intent)的时候,都会调用该Service对象的onStartCommand(Intent,int,int)方法,然后在onStart ...

  8. C#获取时间戳的方法

    获取时间戳的方法 /// <summary>        /// 获取时间戳        /// </summary>        /// <param name= ...

  9. thinking in java知识小记(一)

    知识点一(javadoc): 使用javadoc时特别注意选择encoding和charset为utf-8,要不然生成的javadoc会是乱码,命令:javadoc -encoding utf-8 - ...

  10. mongodb 详解 error:10061 由于目标计算机积极拒绝,无法连接解决方法

    mongodb下载地址(32位):下载地址 自己选择版本 建立如下与mongodb并行的两个文件夹data和log. 然后建立mongo.config. 在mongo.config配置文件中输入: # ...