Class: TxAsr::SentenceRecognition

Inherits:
Object
  • Object
show all
Defined in:
lib/tx_asr/sentence_recognition.rb

Constant Summary collapse

SUB_SERVICE_TYPE =

2 为 一句话识别

2
ACTION =
"SentenceRecognition"
ENG_SERVICE_TYPE_8K_ZH =
"8k_zh"
ENG_SERVICE_TYPE_16K_ZH =
"16k_zh"

Class Method Summary collapse

Class Method Details

.common_payloadObject



17
18
19
20
21
22
23
24
25
# File 'lib/tx_asr/sentence_recognition.rb', line 17

def self.common_payload
  {
    ProjectId: TxAsr.project_id || TxAsr::PROJECT_ID_DEFAULT,
    SubServiceType: SUB_SERVICE_TYPE,
    EngSerViceType: ENG_SERVICE_TYPE_8K_ZH, # 这里的键名是照着文档的,是正确的
    VoiceFormat: TxAsr.voice_format,
    UsrAudioKey: voice_id
  }
end

.from(url) ⇒ Object



11
12
13
14
15
# File 'lib/tx_asr/sentence_recognition.rb', line 11

def self.from(url)
  payload = common_payload.merge({ Url: url })

  Request.new(payload).call(ACTION)
end

.voice_idObject



27
28
29
# File 'lib/tx_asr/sentence_recognition.rb', line 27

def self.voice_id
  SecureRandom.uuid
end