本文整理汇总了Python中say.say函数的典型用法代码示例。如果您正苦于以下问题:Python say函数的具体用法?Python say怎么用?Python say使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了say函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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]))
示例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)
示例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
示例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 )
示例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
示例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))
示例7: test_fourteen
def test_fourteen(self):
self.assertEqual("fourteen", say(14))
示例8: test_number_negative
def test_number_negative(self):
with self.assertRaises(AttributeError):
say(-42)
示例9: test_zero
def test_zero(self):
self.assertEqual("zero", say(0))
示例10: test_fourteen
def test_fourteen(self):
self.assertEqual(say(14), "fourteen")
示例11: test_number_to_large
def test_number_to_large(self):
with self.assertRaises(AttributeError):
say(1e12)
示例12: test_one_hundred
def test_one_hundred(self):
self.assertEqual("one hundred", say(100))
示例13: test_twenty_two
def test_twenty_two(self):
self.assertEqual(say(22), "twenty-two")
示例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))
示例15: test_one_million
def test_one_million(self):
self.assertEqual("one million", say(1e6))