本文整理汇总了Python中say.say函数的典型用法代码示例。如果您正苦于以下问题:Python say函数的具体用法?Python say怎么用?Python say使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了say函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: say_weather
def say_weather(weather):
if weather:
if (weather[0] == 'light rain showers' or weather[0] == 'rain showers' or
weather[0] == 'heavy rain showers' or weather[0] == 'showers'):
say.say('Och så lite väder. Just nu är det {0}, så det kanske är bäst att ni gå till Tegel idag då.'.format(weather[1]))
else:
say.say('Och så lite väder. Just nu är det {0}, så ni kan väl gå vart ni vill.'.format(weather[1]))
开发者ID:permag,项目名称:pyTalk,代码行数:7,代码来源:main.py
示例2: main
def main(mode):
data = get_restaurants()
weather = forecast.get(data['forecast_url'].encode('utf-8'))
# mode
if mode == 'suggestions':
say.say('Här kommer några förslag:')
for item in data['restaurants']:
read_restaurant_menu(item, mode, data['prefered'])
return
elif mode == 'weather':
say_weather(weather)
return
# intro
say_intro()
# get restaurants
for item in data['restaurants']:
read_restaurant_menu(item, mode, None)
# say weather
say_weather(weather)
# Tuesday message
if scraper.get_today_as_string() == 'Tisdag':
say.say(OUTRO_SPECIAL)
开发者ID:permag,项目名称:pyTalk,代码行数:27,代码来源:main.py
示例3: askwolfram
def askwolfram():
import SpeechRecognitionAsk as sra
import wolfquery,say
question = sra.ask()
print(question)
response = wolfquery.wolfquery(question)
say.say(response)
return response
开发者ID:Zenohm,项目名称:Functional-Python-Programs,代码行数:8,代码来源:askwolfram.py
示例4: main
def main(args, debug=False):
fn = args[1] if len(args) > 1 else 'cis.pml'
with open(fn, 'rb') as f:
soup = BeautifulSoup(f)
buf_main = SIO.StringIO()
say.setfiles([buf_main])
say( u'def {_main_atom}():' )
say( u' plist = list()' )
adjuster = None
for index, pml_tag in enumerate( soup.find_all('pml') ):
bufc = SIO.StringIO()
# return "
# <h3>Now, Good Bye...!</h3>
# "
for cld in pml_tag.children:
if isinstance(cld, Tag): # BS4 parses HTML tags in <pml/>!
bufc.write( repr(cld) )
else:
if index == 0: # we get "leading indent" from PML-0
if adjuster == None:
adjuster = LeadingIndent(cld)
else:
cld = adjuster( cld )
bufc.write( cld )
say( bufc.getvalue() )
bufc.close()
say(u' plist.append(pml)') # append that <pml/> Py code ...
# replace <pml/> ==>> <div><!-- pml-N --></div> - for Re.sub
div = soup.new_tag("div")
div.string = Comment( "pml-{}".format(index) )
pml_tag.replace_with( div )
say(u' return plist')
the_code = buf_main.getvalue()
with open("out.py", 'wb') as fp:
fp.write(the_code)
buf_main.close()
if debug == True:
print( the_code )
exec( the_code ) # "execute" (to scope-in) the Py prog
results = pml_code_func() # run the Py-program from <pml> blocks
if debug == True:
pprint( [ item for item in results] )
shtml = soup.prettify(formatter="minimal")
shtml = _comment_re.sub( SubHandler(results), shtml )
print( shtml )
开发者ID:biggers,项目名称:pml-tags-example,代码行数:57,代码来源:cis_pml.py
示例5: say_suggestions
def say_suggestions(name, text_list, prefered):
do_break = False
for pref in prefered:
for s in pref:
s = s.encode('utf-8')
for text in text_list:
text = text.lower()
if text.find(s) != -1:
do_break = True
say.say('På {0} är det {1}.'.format(name, text));
if do_break:
do_break = False
break
开发者ID:permag,项目名称:pyTalk,代码行数:13,代码来源:main.py
示例6: read_restaurant_menu
def read_restaurant_menu(restaurant_item, mode, prefered):
text_list = scraper.get_text_list(restaurant_item['url'])
if not text_list:
return
if mode == 'suggestions':
say_suggestions(restaurant_item['name_pronunciation'], text_list, prefered)
print('\n********* Restaurant: {0} *********'.format(restaurant_item['name']))
i = 0
for text in text_list:
i += 1
print(text)
if mode == 'menu':
if i is 1:
say.say('{0}. {1}'.format(restaurant_item['name_pronunciation'], text))
else:
say.say('. {0}'.format(text))
开发者ID:permag,项目名称:pyTalk,代码行数:16,代码来源:main.py
示例7: test_fourteen
def test_fourteen(self):
self.assertEqual("fourteen", say(14))
开发者ID:michaelkunc,项目名称:python_exercism,代码行数:2,代码来源:say_test.py
示例8: test_number_negative
def test_number_negative(self):
with self.assertRaises(AttributeError):
say(-42)
开发者ID:oalbe,项目名称:exercism,代码行数:3,代码来源:say_test.py
示例9: test_zero
def test_zero(self):
self.assertEqual("zero", say(0))
开发者ID:oalbe,项目名称:exercism,代码行数:2,代码来源:say_test.py
示例10: test_fourteen
def test_fourteen(self):
self.assertEqual(say(14), "fourteen")
开发者ID:Audiodrome,项目名称:exercism,代码行数:2,代码来源:say_test.py
示例11: test_number_to_large
def test_number_to_large(self):
with self.assertRaises(AttributeError):
say(1e12)
开发者ID:oalbe,项目名称:exercism,代码行数:3,代码来源:say_test.py
示例12: test_one_hundred
def test_one_hundred(self):
self.assertEqual("one hundred", say(100))
开发者ID:michaelkunc,项目名称:python_exercism,代码行数:2,代码来源:say_test.py
示例13: test_twenty_two
def test_twenty_two(self):
self.assertEqual(say(22), "twenty-two")
开发者ID:Audiodrome,项目名称:exercism,代码行数:2,代码来源:say_test.py
示例14: test_one_thousand_two_hundred_thirty_four
def test_one_thousand_two_hundred_thirty_four(self):
self.assertEqual("one thousand two hundred and thirty-four", say(1234))
开发者ID:oalbe,项目名称:exercism,代码行数:2,代码来源:say_test.py
示例15: test_one_million
def test_one_million(self):
self.assertEqual("one million", say(1e6))
开发者ID:oalbe,项目名称:exercism,代码行数:2,代码来源:say_test.py
示例16: test_number_negative
def test_number_negative(self):
with self.assertRaisesWithMessage(ValueError):
say(-1)
开发者ID:Audiodrome,项目名称:exercism,代码行数:3,代码来源:say_test.py
示例17: test_zero
def test_zero(self):
self.assertEqual(say(0), "zero")
开发者ID:Audiodrome,项目名称:exercism,代码行数:2,代码来源:say_test.py
示例18: test_number_too_large
def test_number_too_large(self):
with self.assertRaisesWithMessage(ValueError):
say(1e12)
开发者ID:Audiodrome,项目名称:exercism,代码行数:3,代码来源:say_test.py
示例19: test_987654321123
def test_987654321123(self):
self.assertEqual(
say(987654321123), ("nine hundred and eighty-seven billion "
"six hundred and fifty-four million "
"three hundred and twenty-one thousand "
"one hundred and twenty-three"))
开发者ID:Audiodrome,项目名称:exercism,代码行数:6,代码来源:say_test.py
示例20: test_eight_hundred_and_ten_thousand
def test_eight_hundred_and_ten_thousand(self):
self.assertEqual(say(810000), "eight hundred and ten thousand")
开发者ID:Audiodrome,项目名称:exercism,代码行数:2,代码来源:say_test.py
注:本文中的say.say函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论