当前位置: 首页>>代码示例>>Python>>正文


Python flask_ask.statement方法代码示例

本文整理汇总了Python中flask_ask.statement方法的典型用法代码示例。如果您正苦于以下问题:Python flask_ask.statement方法的具体用法?Python flask_ask.statement怎么用?Python flask_ask.statement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask_ask的用法示例。


在下文中一共展示了flask_ask.statement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: play_promoted_songs

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import statement [as 别名]
def play_promoted_songs():
    app.logger.debug("Fetching songs that you have up voted.")

    promoted_songs = api.get_promoted_songs()
    if promoted_songs is False:
        return statement(render_template("play_promoted_songs_no_songs"))

    first_song_id = queue.reset(promoted_songs)
    stream_url = api.get_stream_url(first_song_id)

    if "albumArtRef" in queue.current_track():
        thumbnail = api.get_thumbnail(queue.current_track()['albumArtRef'][0]['url'])
    else:
        thumbnail = None
    speech_text = render_template("play_promoted_songs_text")
    return audio(speech_text).play(stream_url) \
        .standard_card(title=speech_text,
                       text='',
                       small_image_url=thumbnail,
                       large_image_url=thumbnail) 
开发者ID:stevenleeg,项目名称:geemusic,代码行数:22,代码来源:selection.py

示例2: play_album_by_artist

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import statement [as 别名]
def play_album_by_artist(artist_name):
    api = GMusicWrapper.generate_api()
    album = api.get_album_by_artist(artist_name=artist_name)

    if album is False:
        return statement(render_template("no_album"))

    # Setup the queue
    first_song_id = queue.reset(album['tracks'])

    # Start streaming the first track
    stream_url = api.get_stream_url(first_song_id)

    speech_text = render_template("play_album_text",
                                  album=album['name'],
                                  artist=album['albumArtist'])
    return audio(speech_text).play(stream_url) 
开发者ID:stevenleeg,项目名称:geemusic,代码行数:19,代码来源:selection.py

示例3: currently_playing

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import statement [as 别名]
def currently_playing():
    if api.is_indexing():
        return statement(render_template("indexing"))

    track = queue.current_track()

    if track is None:
        return audio(render_template("currently_playing_none"))

    if 'albumArtRef' in queue.current_track():
        thumbnail = api.get_thumbnail(queue.current_track()['albumArtRef'][0]['url'])
    else:
        thumbnail = None
    return statement(render_template("success_title")
                     + render_template("success_text",
                                       song=track['title'],
                                       artist=track['artist']))\
        .standard_card(title=render_template("success_title"),
                       text=render_template("success_text",
                                            song=track['title'],
                                            artist=track['artist']),
                       small_image_url=thumbnail,
                       large_image_url=thumbnail) 
开发者ID:stevenleeg,项目名称:geemusic,代码行数:25,代码来源:playback.py

示例4: list_all_playlists

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import statement [as 别名]
def list_all_playlists():
    if api.is_indexing():
        return statement(render_template("indexing"))

    all_playlists = api.get_all_user_playlist_contents()
    playlist_names = []
    total_playlists = 0
    for i, match in enumerate(all_playlists):

        playlist_names.append(match['name'])
        total_playlists = i + 1

    # Adds "and" before the last playlist to sound more natural when speaking
    if len(playlist_names) >= 3:
        and_placement = len(playlist_names) - 1
        playlist_names.insert(and_placement, render_template("playlist_separator"))

    app.logger.debug(playlist_names)
    playlist_names = ', '.join(playlist_names)

    speech_text = render_template("list_all_playlists_text",
                                  playlist_count=total_playlists,
                                  playlist_list=playlist_names)
    return statement(speech_text) 
开发者ID:stevenleeg,项目名称:geemusic,代码行数:26,代码来源:playback.py

示例5: outside

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import statement [as 别名]
def outside():
    message = random.choice([
        'Awesome.',
        'Good to hear!',
        'Wonderful!',
        'Great!',
    ])

    session.attributes["Outside"] = "Yes"
    session.attributes["State"] = "Suggested"
    response = evaluate_answers()
    if response == "Good job doing all those things. When you're depressed, those little things can be the most difficult.":
        suggestion_inquiry = "Let's try something else to improve your mood."
    else:
        suggestion_inquiry = "Here's an idea for an extra way to improve your mood."
        idea = ideas()

    return statement(message + "      " + suggestion_inquiry + "       " + idea + "          " + "I hope I could help. Would you like another suggestion?") 
开发者ID:Jflick58,项目名称:DepressionAI,代码行数:20,代码来源:voice.py

示例6: alexa_current_playitem_time_remaining

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import statement [as 别名]
def alexa_current_playitem_time_remaining(kodi):
  card_title = render_template('time_left_playing').encode('utf-8')
  log.info(card_title)

  response_text = render_template('nothing_playing').encode('utf-8')

  status = kodi.GetPlayerStatus()
  if status['state'] is not 'stop':
    minsleft = status['total_mins'] - status['time_mins']
    if minsleft == 0:
      response_text = render_template('remaining_close').encode('utf-8')
    elif minsleft == 1:
      response_text = render_template('remaining_min').encode('utf-8')
    elif minsleft > 1:
      response_text = render_template('remaining_mins', minutes=minsleft).encode('utf-8')
      tz = config.get(kodi.dev_cfg_section, 'timezone')
      if minsleft > 9 and tz and tz != 'None':
        utctime = datetime.datetime.now(pytz.utc)
        loctime = utctime.astimezone(pytz.timezone(tz))
        endtime = loctime + datetime.timedelta(minutes=minsleft)
        response_text += render_template('remaining_time', end_time=endtime.strftime('%I:%M')).encode('utf-8')

  return statement(response_text).simple_card(card_title, response_text) 
开发者ID:m0ngr31,项目名称:kanzi,代码行数:25,代码来源:alexa.py

示例7: alexa_listen_recently_added_songs

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import statement [as 别名]
def alexa_listen_recently_added_songs(kodi):
  card_title = render_template('playing_recent_songs').encode('utf-8')
  log.info(card_title)

  response_text = render_template('no_recent_songs').encode('utf-8')

  songs_result = kodi.GetRecentlyAddedSongs()
  if songs_result:
    songs = songs_result['result']['songs']

    songs_array = []
    for song in songs:
      songs_array.append(song['songid'])

    kodi.PlayerStop()
    kodi.ClearAudioPlaylist()
    kodi.AddSongsToPlaylist(songs_array, True)
    kodi.StartAudioPlaylist()
    response_text = render_template('playing_recent_songs').encode('utf-8')

  return statement(response_text).simple_card(card_title, response_text) 
开发者ID:m0ngr31,项目名称:kanzi,代码行数:23,代码来源:alexa.py

示例8: alexa_loop_on

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import statement [as 别名]
def alexa_loop_on(kodi):
  card_title = render_template('loop_enable').encode('utf-8')
  log.info(card_title)

  kodi.PlayerLoopOn()

  response_text = ''

  curprops = kodi.GetActivePlayProperties()
  if curprops is not None:
    if curprops['repeat'] == 'one':
      response_text = render_template('loop_one').encode('utf-8')
    elif curprops['repeat'] == 'all':
      response_text = render_template('loop_all').encode('utf-8')
    elif curprops['repeat'] == 'off':
      response_text = render_template('loop_off').encode('utf-8')

  return statement(response_text).simple_card(card_title, response_text)


# Handle the AMAZON.LoopOffIntent intent. 
开发者ID:m0ngr31,项目名称:kanzi,代码行数:23,代码来源:alexa.py

示例9: play_artist

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import statement [as 别名]
def play_artist(artist_name):
    if not api.use_store and api.is_indexing():
        return statement(render_template("indexing"))

    # Fetch the artist
    artist = api.get_artist(artist_name)

    if artist is False:
        return statement(render_template("play_artist_none", artist=artist_name))

    # Setup the queue
    first_song_id = queue.reset(artist['topTracks'])

    # Get a streaming URL for the top song
    stream_url = api.get_stream_url(first_song_id)

    if "artistArtRef" in artist:
        thumbnail = api.get_thumbnail(artist['artistArtRef'])
    else:
        thumbnail = None
    if api.use_store:
        speech_text = render_template("play_artist_text", artist=artist['name'])
    else:
        speech_text = render_template("play_artist_text_library", artist=artist['name'])
    return audio(speech_text).play(stream_url) \
        .standard_card(title=speech_text,
                       text='',
                       small_image_url=thumbnail,
                       large_image_url=thumbnail) 
开发者ID:stevenleeg,项目名称:geemusic,代码行数:31,代码来源:selection.py

示例10: play_album

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import statement [as 别名]
def play_album(album_name, artist_name):
    if not api.use_store and api.is_indexing():
        return statement(render_template("indexing"))

    app.logger.debug("Fetching album %s" % album_name)

    # Fetch the album
    album = api.get_album(album_name, artist_name)

    if album is False:
        return statement(render_template("no_album"))

    # Setup the queue
    first_song_id = queue.reset(album['tracks'])

    # Start streaming the first track
    stream_url = api.get_stream_url(first_song_id)

    if "albumArtRef" in album:
        thumbnail = api.get_thumbnail(album['albumArtRef'])
    else:
        thumbnail = None
    speech_text = render_template("play_album_text",
                                  album=album['name'],
                                  artist=album['albumArtist'])

    app.logger.debug(speech_text)

    return audio(speech_text).play(stream_url) \
        .standard_card(title=speech_text,
                       text='',
                       small_image_url=thumbnail,
                       large_image_url=thumbnail) 
开发者ID:stevenleeg,项目名称:geemusic,代码行数:35,代码来源:selection.py

示例11: play_song

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import statement [as 别名]
def play_song(song_name, artist_name):
    if not api.use_store and api.is_indexing():
        return statement(render_template("indexing"))

    app.logger.debug("Fetching song %s by %s" % (song_name, artist_name))

    # Fetch the song
    song = api.get_song(song_name, artist_name)

    if song is False:
        return statement(render_template("no_song"))

    # Start streaming the first track
    first_song_id = queue.reset([song])
    stream_url = api.get_stream_url(first_song_id)

    if "albumArtRef" in queue.current_track():
        thumbnail = api.get_thumbnail(queue.current_track()['albumArtRef'][0]['url'])
    else:
        thumbnail = None
    speech_text = render_template("play_song_text",
                                  song=song['title'],
                                  artist=song['artist'])
    return audio(speech_text).play(stream_url) \
        .standard_card(title=speech_text,
                       text='',
                       small_image_url=thumbnail,
                       large_image_url=thumbnail) 
开发者ID:stevenleeg,项目名称:geemusic,代码行数:30,代码来源:selection.py

示例12: play_artist_radio

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import statement [as 别名]
def play_artist_radio(artist_name):
    # TODO -- can we do this without a subscription?
    if not api.use_store:
        return statement(render_template("not_supported_without_store"))

    if not api.use_store and api.is_indexing():
        return statement(render_template("indexing"))

    # Fetch the artist
    artist = api.get_artist(artist_name)

    if artist is False:
        return statement(render_template("no_artist"))

    station_id = api.get_station("%s Radio" % artist['name'],
                                 artist_id=artist['artistId'])
    # TODO: Handle track duplicates (this may be possible using session ids)
    tracks = api.get_station_tracks(station_id)

    first_song_id = queue.reset(tracks)

    # Get a streaming URL for the top song
    stream_url = api.get_stream_url(first_song_id)

    if "albumArtRef" in album:
        thumbnail = api.get_thumbnail(album['albumArtRef'])
    else:
        thumbnail = None
    speech_text = render_template("play_artist_radio_text",
                                  artist=artist['name'])
    return audio(speech_text).play(stream_url) \
        .standard_card(title=speech_text,
                       text='',
                       small_image_url=thumbnail,
                       large_image_url=thumbnail) 
开发者ID:stevenleeg,项目名称:geemusic,代码行数:37,代码来源:selection.py

示例13: play_playlist

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import statement [as 别名]
def play_playlist(playlist_name):
    if not api.use_store and api.is_indexing():
        return statement(render_template("indexing"))

    # Retreve the content of all playlists in a users library
    all_playlists = api.get_all_user_playlist_contents()

    # Get the closest match
    best_match = api.closest_match(playlist_name, all_playlists)

    if best_match is None:
        return statement(render_template("play_playlist_no_match"))

    # Add songs from the playlist onto our queue
    first_song_id = queue.reset(best_match['tracks'])

    # Get a streaming URL for the first song in the playlist
    stream_url = api.get_stream_url(first_song_id)
    if "albumArtRef" in queue.current_track():
        thumbnail = api.get_thumbnail(queue.current_track()['albumArtRef'][0]['url'])
    else:
        thumbnail = None
    speech_text = render_template("play_playlist_text", playlist=best_match['name'])
    return audio(speech_text).play(stream_url) \
        .standard_card(title=speech_text,
                       text='',
                       small_image_url=thumbnail,
                       large_image_url=thumbnail) 
开发者ID:stevenleeg,项目名称:geemusic,代码行数:30,代码来源:selection.py

示例14: queue_song

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import statement [as 别名]
def queue_song(song_name, artist_name):
    app.logger.debug("Queuing song %s by %s" % (song_name, artist_name))

    if len(queue.song_ids) == 0:
        return statement(render_template("queue_song_no_song"))

    # Fetch the song
    song = api.get_song(song_name, artist_name)

    if song is False:
        return statement(render_template("no_song"))

    # Queue the track in the list of song_ids
    queue.enqueue_track(song)
    stream_url = api.get_stream_url(song)
    card_text = render_template("queue_song_queued",
                                song=song['title'],
                                artist=song['artist'])
    if "albumArtRef" in queue.current_track():
        thumbnail = api.get_thumbnail(queue.current_track()['albumArtRef'][0]['url'])
    else:
        thumbnail = None
    return audio().enqueue(stream_url) \
        .standard_card(title=card_text,
                       text='',
                       small_image_url=thumbnail,
                       large_image_url=thumbnail) 
开发者ID:stevenleeg,项目名称:geemusic,代码行数:29,代码来源:selection.py

示例15: list_album_by_artists

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import statement [as 别名]
def list_album_by_artists(artist_name):
    # TODO -- can we do this without a subscription?
    if not api.use_store:
        return statement(render_template("not_supported_without_store"))

    api = GMusicWrapper.generate_api()
    artist_album_list = api.get_artist_album_list(artist_name=artist_name)
    return statement(artist_album_list) 
开发者ID:stevenleeg,项目名称:geemusic,代码行数:10,代码来源:selection.py


注:本文中的flask_ask.statement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。