【发布时间】:2017-12-28 05:55:17
【问题描述】:
我正在尝试从以下结果中获取“成绩单”值:
{
transcript: "1 2 3 4"
confidence: 0.902119
words {
start_time {
nanos: 200000000
}
end_time {
nanos: 700000000
}
word: "1"
}
words {
start_time {
nanos: 700000000
}
end_time {
nanos: 900000000
}
word: "2"
}
words {
start_time {
nanos: 900000000
}
end_time {
seconds: 1
}
word: "3"
}
words {
start_time {
seconds: 1
}
end_time {
seconds: 1
nanos: 300000000
}
word: "4"
}
}
我写的代码是:
对于results.resultsArray中的结果! {
if let result = result as? StreamingRecognitionResult {
for alternative in result.alternativesArray {
if let alternative = alternative as? StreamingRecognitionResult {
textView.text = "\(alternative["transcript"])"
}
}
}
}
因此,当我尝试将值放入 textview.text 时,我收到一条错误消息:
“类型'StreamingRecognitionResult'没有下标成员”。
请帮忙。
【问题讨论】:
标签: ios swift speech-to-text google-speech-api google-cloud-speech