Ruby Alexa启动AudioPlayer.PlaybackStopped意图AudioPlayer.PlaybackStopped意图4秒后 背景:

Ruby Alexa启动AudioPlayer.PlaybackStopped意图AudioPlayer.PlaybackStopped意图4秒后 背景:,ruby,sinatra,alexa,Ruby,Sinatra,Alexa,通过与ruby sinatra、ralyxa gem和ngrok合作,将my local设置为端点,我无法找到Alexa“自行”触发此事件的原因 意向书如下: current_https_host = 'https://0eaf626d.ngrok.io' default_token = '1234AAAABBBBCCCCCDDDDEEEEEFFFF' short_mp3 = 'count_1_to_15.mp3' start_offset = 0 intent 'son_du_jour' d

通过与ruby sinatra、ralyxa gem和ngrok合作,将my local设置为端点,我无法找到Alexa“自行”触发此事件的原因

意向书如下:

current_https_host = 'https://0eaf626d.ngrok.io'
default_token = '1234AAAABBBBCCCCCDDDDEEEEEFFFF'
short_mp3 = 'count_1_to_15.mp3'
start_offset = 0

intent 'son_du_jour' do
  token = request.user_access_token || default_token
  audio_player.play(
    "#{current_https_host}/#{short_mp3}",
    token,
    offset_in_milliseconds: start_offset
  ).to_json
end
sinatra服务器的日志显示,alexa发出的双音信号中断了以下第11行

日志 虽然亚马逊打算这样看:

require 'byebug'
require 'logger'

logger = Logger.new STDOUT
empty_response = {
  version: '1.0',
  response: {
    shouldEndSession: true
  }
}.to_json

intent 'LaunchRequest' do
  message = "<audio src='soundbank://soundlibrary/home/amzn_sfx_door_open_01'/>Bonjour! Que voulez-vous écouter ?"
  intonation_message = "<speak>#{message}</speak>"
  ask(intonation_message, ssml: true).to_json
end

intent 'AMAZON.StopIntent' do
  tell('Bye Bye !')
end

intent 'AudioPlayer.PlaybackStarted' do
  logger.debug('Playback starts here ...')
  logger.debug(
    'offsetInMilliseconds : ' \
    "#{request.request['request']['offsetInMilliseconds']}"
  )
  empty_response
end

intent 'AudioPlayer.PlaybackStopped' do
  logger.debug('PlaybackStopped: interruption with a bi-tone')
  logger.debug(
    'offsetInMilliseconds : ' \
    "#{request.request['request']['offsetInMilliseconds']}"
  )
  empty_response
end

intent 'AudioPlayer.PlaybackNearlyFinished' do
  logger.debug('Time to add up another playback from the list')
  empty_response
end

intent 'AudioPlayer.PlaybackFinished' do
  error_count = 0
  logger.debug('PlaybackFinished intent fired')
  (JSON.parse audio_player.stop).tap do |response|
    response['response']['shouldEndSession'] = true
  end.to_json
end

intent 'System.ExceptionEncountered' do
  failure_details = request.request['request']
  error_details = failure_details['error']
  logger.debug("Error timestamp : #{failure_details['timestamp']}")
  logger.error('Error details (message) : ' \
               "##{error_count} - #{error_details['message']}")
end

需要“byebug”
需要“记录器”
logger=logger.new标准输出
空\u响应={
版本:“1.0”,
答复:{
shouldEndSession:true
}
}.to_json
意向“启动请求”do
message=“您好!您好吗?”
语调_message=“#{message}”
ask(语调信息,ssml:true)
结束
意图“AMAZON.StopIntent”do
告诉我(“再见!”)
结束
意图“AudioPlayer.PlaybackStarted”do
debug('从这里开始播放…')
logger.debug(
'偏移毫秒:'\
“{request.request['request']['offset']}”
)
空响应
结束
意图“音频播放器。播放支持”do
debug('PlaybackStopped:双音中断')
logger.debug(
'偏移毫秒:'\
“{request.request['request']['offset']}”
)
空响应
结束
意图“AudioPlayer.PlaybackNearlyFinished”执行
debug('从列表中添加另一个播放的时间')
空响应
结束
意图“音频播放器。播放”执行
错误计数=0
logger.debug('playimpaized intent fired')
(JSON.parse audio_player.stop)。点击do | response|
响应['response']['shouldEndSession']=true
end.to_json
结束
“意图”系统。例外反制“do
失败\u详细信息=请求。请求['request']
错误详细信息=失败详细信息['error']
debug(“错误时间戳:#{failure_details['timestamp']}”)
logger.error('错误详细信息(消息):'\
“##{error_count}-#{error_details['message']}”)
结束
中断不会让mp3文件的读取重新开始,它只会发出嘟嘟声(双音),然后自行暂停并恢复流读取。 我想知道之前的意图响应是否是导致播放中断的实际原因。任何想法都会有帮助

require 'byebug'
require 'logger'

logger = Logger.new STDOUT
empty_response = {
  version: '1.0',
  response: {
    shouldEndSession: true
  }
}.to_json

intent 'LaunchRequest' do
  message = "<audio src='soundbank://soundlibrary/home/amzn_sfx_door_open_01'/>Bonjour! Que voulez-vous écouter ?"
  intonation_message = "<speak>#{message}</speak>"
  ask(intonation_message, ssml: true).to_json
end

intent 'AMAZON.StopIntent' do
  tell('Bye Bye !')
end

intent 'AudioPlayer.PlaybackStarted' do
  logger.debug('Playback starts here ...')
  logger.debug(
    'offsetInMilliseconds : ' \
    "#{request.request['request']['offsetInMilliseconds']}"
  )
  empty_response
end

intent 'AudioPlayer.PlaybackStopped' do
  logger.debug('PlaybackStopped: interruption with a bi-tone')
  logger.debug(
    'offsetInMilliseconds : ' \
    "#{request.request['request']['offsetInMilliseconds']}"
  )
  empty_response
end

intent 'AudioPlayer.PlaybackNearlyFinished' do
  logger.debug('Time to add up another playback from the list')
  empty_response
end

intent 'AudioPlayer.PlaybackFinished' do
  error_count = 0
  logger.debug('PlaybackFinished intent fired')
  (JSON.parse audio_player.stop).tap do |response|
    response['response']['shouldEndSession'] = true
  end.to_json
end

intent 'System.ExceptionEncountered' do
  failure_details = request.request['request']
  error_details = failure_details['error']
  logger.debug("Error timestamp : #{failure_details['timestamp']}")
  logger.error('Error details (message) : ' \
               "##{error_count} - #{error_details['message']}")
end