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的更多相关文章
- Check iO:初学Python
The end of other For language training our Robots want to learn about suffixes. In this task, you ar ...
- [官网]Windows modules
Windows modules https://docs.ansible.com/ansible/latest/modules/list_of_windows_modules.html win_acl ...
- 百度语音+react+loopback实现语音合成返回播放
1.在百度语音中创建自己的项目,需要拿到APP_ID.API_KEY.SECRET_KEY. 2.loopback端提供接口服务,在./boot目录下新建root.js文件,编写不依赖模型的自定义接口 ...
- 【Python CheckiO 题解】SP
题目描述 [Speech Module]:输入一个数字,将其转换成英文表达形式,字符串中的所有单词必须以一个空格字符分隔. [输入]:一个数字(int) [输出]:代表数字的英文字符串(str) [前 ...
- Understanding C++ Modules In C++20 (1)
Compiling evironment: linux (ubuntu 16.04)+ gcc-10.2. The Post will clarify and discuss what modules ...
- 自然语言15_Part of Speech Tagging with NLTK
https://www.pythonprogramming.net/part-of-speech-tagging-nltk-tutorial/?completed=/stemming-nltk-tut ...
- 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 ...
- 论文翻译:2020_A Recursive Network with Dynamic Attention for Monaural Speech Enhancement
论文地址:基于动态注意的递归网络单耳语音增强 论文代码:https://github.com/Andong-Li-speech/DARCN 引用格式:Li, A., Zheng, C., Fan, C ...
- 论文翻译: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 ...
随机推荐
- NSIS如何对一整个目录文件夹(包括子文件夹和其中的文件)压缩
原来不加/r参数,NSIS编译器就会不认识文件夹啊. File /r [dir] Reference: http://stackoverflow.com/questions/7973242/nsis- ...
- BZOJ2023: [Usaco2005 Nov]Ant Counting 数蚂蚁
2023: [Usaco2005 Nov]Ant Counting 数蚂蚁 Time Limit: 4 Sec Memory Limit: 64 MBSubmit: 56 Solved: 16[S ...
- java基础进阶:SQL的运用
SQL的基础的运用 /* --1.学生表 Student(S,Sname,Sage,Ssex) --S 学生编号,Sname 学生姓名,Sage 出生年月,Ssex 学生性别 --2.课程表 Cour ...
- poj:2992 因子数量
题意: 求 组合数c(n,k)的因子数量 由算术基本定理很容易求得,不过第一次却T了,加了好多预处理,o1查询,才过 #include <iostream> #include <st ...
- 人人必知的10个jQuery小技巧
收集的10个 jQuery 小技巧/代码片段,可以帮你快速开发. 1.返回顶部按钮 你可以利用 animate 和 scrollTop 来实现返回顶部的动画,而不需要使用其他插件. // Back t ...
- javascript笔记3之数据类型
/* var box = 250; //十进制整型 alert(box); var box = 070; //八进制,按照十进制输出是56 alert(box); var box = 0x1f; // ...
- WPF - 使用Microsoft.Win32.OpenFileDialog打开文件,使用Microsoft.Win32.SaveFileDialog将文件另存
1. WPF 使用这个方法打开文件,很方便,而且可以记住上次打开的路径. Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.W ...
- poj 2112 Optimal Milking (二分图匹配的多重匹配)
Description FJ has moved his K ( <= K <= ) milking machines <= C <= ) cows. A ..K; the c ...
- 常用的js对象扩展方法
1. 字符串的replaceAll String.prototype.replaceAll = function(reallyDo, replaceWith, ignoreCase) { if (!R ...
- C++ MPICH
假设一个C++的MPI程序在单机上能够跑.可是在多机上跑会报下面错误: Fatal error in MPI_Send: Unkown error class , error stack. 解决方法: ...