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. Cmake 脚本对预处理器的宏定义

    我们有些时候会在#if   #ifndef   等预编译命令里面看到_WIN32等定义的宏.但是有些宏定义,你即使通过Visual Studio右键的go to definitions 和go to ...

  2. poj2752 Seek the Name, Seek the Fame

    Description The little cat is so famous, that many couples tramp over hill and dale to Byteland, and ...

  3. DL,DT,DD,比传统table更语义,解析更快的table列表方式

    使用dl,dt,dd替代传统的table布局 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" & ...

  4. hdu 5167 Fibonacci(预处理)

    Problem Description Following is the recursive definition of Fibonacci sequence: Fi=⎧⎩⎨01Fi−1+Fi−2i ...

  5. C# 酒鬼买酒喝,瓶盖和空瓶子可以换新的酒

        using System; using System.Collections.Generic; using System.Linq; using System.Text; using Syst ...

  6. <微信应用开发系列>定时刷新AccessToken

    微信内嵌H5站一直很火,很多公司也想借助微信的用户群和社交群来做点事情,所以对于各位代码君来说也算是一个研究方向吧. access_token是公众号的全局唯一票据,公众号调用各接口时都需使用acce ...

  7. sql server windows账号不能登陆指定的数据库

    问题描述: 1. windows账号登陆后,默认的数据库被删除 2. SA账号密码也忘记了 此时就会导致用windows账号登陆Sql Server的时候,返回4064的错误,按照上面的问题描述,应该 ...

  8. AngularJs练习Demo10 ngInclude

    @{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewport&quo ...

  9. JS如何得到Repeater中TextBox控件的值

    var subsidylCost = document.getElementById("txtSubsidylCost.ClientID").value; 这样获取不到,因为txt ...

  10. android 开发中判断网络是否连接的代码

    在android的开发中,尤其是与访问网络有关的开发,都要判断一下手机是否连接上了网络,下面是一个判断是否连接网络的嗲吗片段: package cn.com.karl.util; import com ...