本文整理汇总了Python中melissa.tts.tts函数的典型用法代码示例。如果您正苦于以下问题:Python tts函数的具体用法?Python tts怎么用?Python tts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tts函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_pyvona
def test_pyvona(self, mock_sys, mock_subprocess):
"""test pyvona."""
random_gender = get_random_string(
exclude_list=('female', 'male')
)
mock_access_key = mock.Mock()
mock_secret_key = mock.Mock()
for gender in ('male', 'female', random_gender):
mock_profile.data = {
'va_gender': gender,
'tts': 'ivona',
'ivona': {
'access_key': mock_access_key,
'secret_key': mock_secret_key,
}
}
with mock.patch('melissa.tts.pyvona') as mock_pyvona:
tts(self.message)
# test voice name
assert len(mock_pyvona.mock_calls) == 2
# test voice name
if gender == 'female':
assert mock_pyvona.create_voice().voice_name == 'Salli'
elif gender == 'male':
assert mock_pyvona.create_voice().voice_name == 'Joey'
else:
assert mock_pyvona.create_voice().voice_name == 'Joey'
create_voice_call = mock.call.create_voice(
mock_access_key, mock_secret_key
)
assert create_voice_call in mock_pyvona.mock_calls
engine_speak_call = mock.call.create_voice().speak(
self.message
)
assert engine_speak_call in mock_pyvona.mock_calls
开发者ID:Melissa-AI,项目名称:Melissa-Core,代码行数:35,代码来源:test_tts.py
示例2: post_tweet
def post_tweet(text):
if profile.data['twitter']['consumer_key'] == "xxxx" \
or profile.data['twitter']['consumer_secret'] == "xxxx" \
or profile.data['twitter']['access_token'] == "xxxx" \
or profile.data['twitter']['access_token_secret'] == "xxxx":
msg = 'twitter requires a consumer key and secret, and an access token and token secret.'
print msg
tts(msg)
return;
words_of_message = text.split()
words_of_message.remove('tweet')
cleaned_message = ' '.join(words_of_message).capitalize()
auth = tweepy.OAuthHandler(
profile.data['twitter']['consumer_key'],
profile.data['twitter']['consumer_secret'])
auth.set_access_token(
profile.data['twitter']['access_token'],
profile.data['twitter']['access_token_secret'])
api = tweepy.API(auth)
api.update_status(status=cleaned_message)
tts('Your tweet has been posted')
开发者ID:EricChen2013,项目名称:Melissa-Core,代码行数:27,代码来源:twitter_interaction.py
示例3: how_am_i
def how_am_i(text):
replies = [
'You are goddamn handsome!',
'My knees go weak when I see you.',
'You are sexy!',
'You look like the kindest person that I have met.'
]
tts(random.choice(replies))
开发者ID:Melissa-AI,项目名称:Melissa-Core,代码行数:8,代码来源:general_conversations.py
示例4: test_random_platform
def test_random_platform(self, mock_sys, mock_subprocess):
"""test random platform."""
mock_sys.platform = get_random_string(
exclude_list=('linux', 'darwin', 'win32')
)
tts(self.message)
# empty list/mock_subprocess not called
assert not mock_subprocess.mock_calls
开发者ID:Melissa-AI,项目名称:Melissa-Core,代码行数:8,代码来源:test_tts.py
示例5: test_default_mock
def test_default_mock(self, mock_sys, mock_subprocess):
"""test using default mock obj."""
tts(self.message)
# NOTE: the default for linux/win32 with gender male.
# ( see non-exitent 'ven+f3' flag)
mock_call = mock.call.call(['espeak', '-s170', self.message])
assert mock_call in mock_subprocess.mock_calls
assert len(mock_subprocess.mock_calls) == 1
开发者ID:Melissa-AI,项目名称:Melissa-Core,代码行数:8,代码来源:test_tts.py
示例6: go_to_sleep
def go_to_sleep(text):
replies = ['See you later!', 'Just call my name and I\'ll be there!']
tts(random.choice(replies))
if profile.data['hotword_detection'] == 'on':
print('\nListening for Keyword...')
print('Press Ctrl+C to exit')
quit()
开发者ID:Melissa-AI,项目名称:Melissa-Core,代码行数:9,代码来源:sleep.py
示例7: show_all_uploads
def show_all_uploads(text):
conn = sqlite3.connect(profile.data['memory_db'])
cursor = conn.execute("SELECT * FROM image_uploads")
for row in cursor:
print(row[0] + ': (' + row[1] + ') on ' + row[2])
tts('Requested data has been printed on your terminal')
conn.close()
开发者ID:EricChen2013,项目名称:Melissa-Core,代码行数:10,代码来源:imgur_handler.py
示例8: show_all_notes
def show_all_notes(text):
conn = sqlite3.connect(profile.data['memory_db'])
tts('Your notes are as follows:')
cursor = conn.execute("SELECT notes FROM notes")
for row in cursor:
tts(row[0])
conn.close()
开发者ID:Melissa-AI,项目名称:Melissa-Core,代码行数:10,代码来源:notes.py
示例9: play_shuffle
def play_shuffle(text):
try:
mp3gen()
random.shuffle(music_listing)
for i in range(0, len(music_listing)):
music_player(music_listing[i])
except IndexError as e:
tts('No music files found.')
print("No music files found: {0}".format(e))
开发者ID:EricChen2013,项目名称:Melissa-Core,代码行数:10,代码来源:play_music.py
示例10: note_something
def note_something(speech_text):
conn = sqlite3.connect(profile.data['memory_db'])
words_of_message = speech_text.split()
words_of_message.remove('note')
cleaned_message = ' '.join(words_of_message)
conn.execute("INSERT INTO notes (notes, notes_date) VALUES (?, ?)", (cleaned_message, datetime.strftime(datetime.now(), '%d-%m-%Y')))
conn.commit()
conn.close()
tts('Your note has been saved.')
开发者ID:EricChen2013,项目名称:Melissa-Core,代码行数:11,代码来源:notes.py
示例11: system_status
def system_status(text):
os, name, version, _, _, _ = platform.uname()
version = version.split('-')[0]
cores = psutil.cpu_count()
cpu_percent = psutil.cpu_percent()
memory_percent = psutil.virtual_memory()[2]
response = "I am currently running on %s version %s. " %(os, version)
response += "This system is named %s and has %s CPU cores. " %(name, cores)
response += "Current CPU utilization is %s percent. " %cpu_percent
response += "Current memory utilization is %s percent." %memory_percent
tts(response)
开发者ID:EricChen2013,项目名称:Melissa-Core,代码行数:11,代码来源:system_status.py
示例12: play_random
def play_random(text):
try:
mp3gen()
music_playing = random.choice(music_listing)
song_name = os.path.splitext(basename(music_playing[1]))[0]
tts("Now playing: " + song_name)
music_player(music_playing)
except IndexError as e:
tts('No music files found.')
print("No music files found: {0}".format(e))
开发者ID:EricChen2013,项目名称:Melissa-Core,代码行数:11,代码来源:play_music.py
示例13: weather
def weather(text):
weather_com_result = pywapi.get_weather_from_weather_com(profile.data['city_code'])
temperature = float(weather_com_result['current_conditions']['temperature'])
degrees_type = 'celcius'
if profile.data['degrees'] == 'fahrenheit':
temperature = (temperature * 9/5) + 32
degrees_type = 'fahrenheit'
weather_result = "Weather.com says: It is " + weather_com_result['current_conditions']['text'].lower() + " and " + str(temperature) + "degrees "+ degrees_type +" now in " + profile.data['city_name']
tts(weather_result)
开发者ID:EricChen2013,项目名称:Melissa-Core,代码行数:12,代码来源:weather.py
示例14: find_iphone
def find_iphone(text):
try:
api = PyiCloudService(ICLOUD_USERNAME, ICLOUD_PASSWORD)
except PyiCloudFailedLoginException:
tts("Invalid Username & Password")
return
# All Devices
devices = api.devices
# Just the iPhones
iphones = []
for device in devices:
current = device.status()
if "iPhone" in current['deviceDisplayName']:
iphones.append(device)
# The one to ring
phone_to_ring = None
if len(iphones) == 0:
tts("No iPhones found in your account")
return
elif len(iphones) == 1:
phone_to_ring = iphones[0]
phone_to_ring.play_sound()
tts("Sending ring command to the phone now")
elif len(iphones) > 1:
for phone in iphones:
phone_to_ring = phone
phone_to_ring.play_sound()
tts("Sending ring command to the phone now")
开发者ID:Melissa-AI,项目名称:Melissa-Core,代码行数:35,代码来源:find_iphone.py
示例15: tell_joke
def tell_joke(text):
jokes = [
'What happens to a frogs car when it breaks down? It gets toad away.',
'Why was six scared of seven? Because seven ate nine.',
'Why are mountains so funny? Because they are hill areas.',
'Have you ever tried to eat a clock?'
'I hear it is very time consuming.',
'What happened when the wheel was invented? A revolution.',
'What do you call a fake noodle? An impasta!',
'Did you hear about that new broom? It is sweeping the nation!',
'What is heavy forward but not backward? Ton.',
'No, I always forget the punch line.'
]
tts(random.choice(jokes))
开发者ID:Melissa-AI,项目名称:Melissa-Core,代码行数:14,代码来源:general_conversations.py
示例16: main
def main():
data = load_profile(True)
tts('Welcome ' + data['name'] +
', how can I help you?')
while True:
if sys.platform == 'darwin':
subprocess.call(['afplay', 'data/snowboy_resources/ding.wav'])
elif sys.platform.startswith('linux') or sys.platform == 'win32':
subprocess.call(['mpg123', 'data/snowboy_resources/ding.wav'])
text = stt()
if text is None:
continue
else:
query(text)
开发者ID:Melissa-AI,项目名称:Melissa-Core,代码行数:17,代码来源:start.py
示例17: test_darwin_platform
def test_darwin_platform(self, mock_sys, mock_subprocess):
"""test darwin platform."""
random_gender = get_random_string(exclude_list=('female', 'male'))
# tuple contain (gender, mock_call)
data = (
(None, lambda x: mock.call.call(['say', x])),
(random_gender, lambda x: mock.call.call(['say', x])),
('female', lambda x: mock.call.call(['say', x])),
('male', lambda x: mock.call.call(['say', '-valex', x])),
)
mock_sys.platform = 'darwin'
for gender, mock_call in data:
if gender is not None:
DEFAULT_PROFILE_DATA['va_gender'] = gender
mock_profile.data = DEFAULT_PROFILE_DATA
tts(self.message)
# NOTE: the default for macos with gender female.
# (it don't have 'valex' flag)
assert mock_call(self.message) in mock_subprocess.mock_calls
assert len(mock_subprocess.mock_calls) == 1
mock_subprocess.reset_mock()
开发者ID:Melissa-AI,项目名称:Melissa-Core,代码行数:21,代码来源:test_tts.py
示例18: define_subject
def define_subject(speech_text):
words_of_message = speech_text.split()
words_of_message.remove('define')
cleaned_message = ' '.join(words_of_message).rstrip()
if len(cleaned_message) == 0:
msg = 'define requires subject words'
print msg
tts(msg)
return
try:
wiki_data = wikipedia.summary(cleaned_message, sentences=5)
regEx = re.compile(r'([^\(]*)\([^\)]*\) *(.*)')
m = regEx.match(wiki_data)
while m:
wiki_data = m.group(1) + m.group(2)
m = regEx.match(wiki_data)
wiki_data = wiki_data.replace("'", "")
tts(wiki_data)
except wikipedia.exceptions.DisambiguationError as e:
tts('Can you please be more specific? You may choose something' +
'from the following.')
print("Can you please be more specific? You may choose something" +
"from the following; {0}".format(e))
开发者ID:Melissa-AI,项目名称:Melissa-Core,代码行数:26,代码来源:define_subject.py
示例19: image_uploader
def image_uploader(speech_text):
if profile.data['imgur']['client_id'] == "xxxx" \
or profile.data['imgur']['client_secret'] == "xxxx":
msg = 'upload requires a client id and secret'
print msg
tts(msg)
return;
words_of_message = speech_text.split()
words_of_message.remove('upload')
cleaned_message = ' '.join(words_of_message)
if len(cleaned_message) == 0:
tts('upload requires a picture name')
return;
image_listing = img_list_gen()
client = ImgurClient(profile.data['imgur']['client_id'],
profile.data['imgur']['client_secret'])
for i in range(0, len(image_listing)):
if cleaned_message in image_listing[i]:
result = client.upload_from_path(image_listing[i], config=None, anon=True)
conn = sqlite3.connect(profile.data['memory_db'])
conn.execute("INSERT INTO image_uploads (filename, url, upload_date) VALUES (?, ?, ?)", (image_listing[i], result['link'], datetime.strftime(datetime.now(), '%d-%m-%Y')))
conn.commit()
conn.close()
print result['link']
tts('Your image has been uploaded')
开发者ID:EricChen2013,项目名称:Melissa-Core,代码行数:32,代码来源:imgur_handler.py
示例20: iphone_battery
def iphone_battery(text):
try:
api = PyiCloudService(ICLOUD_USERNAME, ICLOUD_PASSWORD)
except PyiCloudFailedLoginException:
tts("Invalid Username & Password")
return
# All Devices
devices = api.devices
# Just the iPhones
iphones = []
for device in devices:
current = device.status()
if "iPhone" in current['deviceDisplayName']:
iphones.append(device)
for phone in iphones:
status = phone.status()
battery = str(int(float(status['batteryLevel']) * 100))
tts(battery + 'percent battery left in ' + status['name'])
开发者ID:Melissa-AI,项目名称:Melissa-Core,代码行数:22,代码来源:find_iphone.py
注:本文中的melissa.tts.tts函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论