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. android 无法生成R文件的原因剖析

    android 无法生成R文件 是件痛苦的事情,即使有时候你xml文件没有错误,他都无法生成.针对此问题,我总结以下几个方面的原因. 一.xml本身有错误 R.java这个文件是会自动生成的,但是如果 ...

  2. SQL之用户自定义函数

    关于SQL Server用户自定义的函数,有标量函数.表值函数(内联表值函数.多语句表值函数)两种. 题外话,可能有部分朋友不知道SQL Serve用户自定义的函数应该是写在哪里,这里简单提示一下,在 ...

  3. HTML5 拼图游戏

    点击之后被选中的切片会变为透明 源代码 点击打开链接

  4. PHP基础设计模式——工厂模式

    <?php//文件名:Factory namespace IMooc; class Factory { //工程模式 static function creatDatabase() { $db ...

  5. Java中普通代码块,构造代码块,静态代码块的代码演示样例及区分

    //运行顺序:(优先级从高到低.)静态代码块>mian方法>构造代码块>构造方法. 当中静态代码块仅仅运行一次.构造代码块在每次创建对象是都会运行. 1 普通代码块 <span ...

  6. js将日期格式的时候转换成时间搓

    自己写的一个方法 function split_time(time){//将当前时间转换成时间搓  例如2013-09-11 12:12:12   var arr=time.split(" ...

  7. Android调用系统邮件类应用的正确实现方法

    Android应用开发中,很多情况下免不了要调用手机上的邮件类应用,实现邮件发送的功能,这一般是通过调用系统已有的Intent来实现的.看到网上很多邮件发送都是调用action为android.con ...

  8. 使用VTemplate模板引擎动态生成订单流程图

    1.VTemplate模板引擎的简介 VTemplate模板引擎也简称为VT,是基于.NET的模板引擎,它允许任何人使用简单的类似HTML语法的模板语言来引用.NET里定义的对象.当VTemplate ...

  9. Web Service学习笔记(webservice、soap、wsdl、jws详细分析) (转)

    Web Service概述 Web Service的定义 W3C组织对其的定义如下,它是一个软件系统,为了支持跨网络的机器间相互操作交互而设计.Web Service服务通常被定义为一组模块化的API ...

  10. NFinal 揭秘之控制器

    用NFinal框架开发的项目类似于MVC的那种开发方式,有Controller层.Model层.View层,还包括表现层Web层,在NFinal开发的项目中真正执行的代码也就是Web层中的代码,Web ...