响应元数据
IBM Watson® Speech to Text 服务可以返回三种类型的元数据,说明其转录结果。 您可以要求获得尽可能多的备选方案,以查看多种可能的最终转录结果。 您还可以请求单词置信度和单词时间戳,以获取音频中每个单词的置信度和时间戳。
最大替代项数
max_alternatives
参数接受整数值,用于指示服务返回结果的 n 个最佳替代假设。 默认情况下,该服务仅返回一个转录结果,相当于将参数设置为 1
。 将 max_alternatives
设置为大于1的数字,您要求服务返回该数字的最佳替代转录。 (如果指定值 0
,那么服务将使用缺省值 1
。)
服务仅会针对所返回的最佳替代项报告置信度分数。 在大多数情况下,这是要选择的替代项。
服务的内部变化和改进可能会影响成绩单和信心分数。 例如,语音识别可以得到改进,从而提供更精确的转录结果。 同样,转录和单词置信度评分可能会因语音识别能力的提高而略有变化。 预计这些变化不会很大,但不要指望成绩单和信心分数会一直保持不变。
最大替代项数示例
以下示例请求将 max_alternatives
参数设置为 3
:
IBM Cloud
curl -X POST -u "apikey:{apikey}" \
--header "Content-Type: audio/flac" \
--data-binary @{path}audio-file.flac \
"{url}/v1/recognize?max_alternatives=3"
IBM Cloud Pak for Data IBM Software Hub
curl -X POST \
--header "Authorization: Bearer {token}" \
--header "Content-Type: audio/flac" \
--data-binary @{path}audio-file.flac \
"{url}/v1/recognize?max_alternatives=3"
服务报告仅对三种可能性中的一种给出可信度:
{
"result_index": 0,
"results": [
{
"alternatives": [
{
"confidence": 0.96,
"transcript": "several tornadoes touch down as a line of
severe thunderstorms swept through Colorado on Sunday "
},
{
"transcript": "several tornadoes touched down as a line of
severe thunderstorms swept through Colorado on Sunday "
},
{
"transcript": "several tornadoes touch down as a line of
severe thunderstorms swept through Colorado and Sunday "
}
],
"final": true
}
]
}
词置信度
word_confidence
参数指示服务是否为转录中的词提供置信度度量。 缺省情况下,服务仅将最终文字记录作为整体报告置信度度量。 将 word_confidence
设置为 true
会指示服务为文字记录中的每个单独的词报告置信度度量。
置信度度量指示服务基于声学证据对转录词正确性的估计。 置信度分数范围为 0.0 到 1.0。
- 分数为 1.0 表示词的当前转录反映了最有可能的结果。
- 分数为 0.5 表示词正确的可能性为 50%。
服务的内部变化和改进可能会影响成绩单和信心分数。 例如,语音识别可以得到改进,从而提供更精确的转录结果。 同样,转录和单词置信度评分可能会因语音识别能力的提高而略有变化。 预计这些变化不会很大,但不要指望成绩单和信心分数会一直保持不变。
词置信度示例
以下示例请求转录文本中单词的置信度得分:
IBM Cloud
curl -X POST -u "apikey:{apikey}" \
--header "Content-Type: audio/flac" \
--data-binary @{path}audio-file.flac \
"{url}/v1/recognize?word_confidence=true"
IBM Cloud Pak for Data IBM Software Hub
curl -X POST \
--header "Authorization: Bearer {token}" \
--header "Content-Type: audio/flac" \
--data-binary @{path}audio-file.flac \
"{url}/v1/recognize?word_confidence=true"
该服务会为音频中的每个单词返回一个信心度评分:
{
"result_index": 0,
"results": [
{
"alternatives": [
{
"confidence": 0.96,
"transcript": "several tornadoes touch down as a line of
severe thunderstorms swept through Colorado on Sunday ",
"word_confidence": [
[
"several",
1.0
],
[
"tornadoes",
1.0
],
[
"touch",
0.52
],
[
"down",
0.90
],
. . .
[
"on",
0.31
],
[
"Sunday",
0.99
]
]
}
],
"final": true
}
]
}
词时间戳记
timestamps
参数指示服务是否为其转录的词生成时间戳记。 缺省情况下,服务不会报告时间戳记。 将 timestamps
设置为 true
会指示服务报告每个词相对于音频开头的开始时间和结束时间(以秒为单位)。
当您请求发言者标签时,时间戳会自动启用。 有关更多信息,请参阅说话者标签。
词时间戳记示例
以下示例请求为转录文本中的单词添加时间戳:
IBM Cloud
curl -X POST -u "apikey:{apikey}" \
--header "Content-Type: audio/flac" \
--data-binary @{path}audio-file.flac \
"{url}/v1/recognize?timestamps=true"
IBM Cloud Pak for Data IBM Software Hub
curl -X POST \
--header "Authorization: Bearer {token}" \
--header "Content-Type: audio/flac" \
--data-binary @{path}audio-file.flac \
"{url}/v1/recognize?timestamps=true"
该服务会为音频中的每个单词返回一个时间戳:
{
"result_index": 0,
"results": [
{
"alternatives": [
{
"timestamps": [
[
"several",
1.01,
1.52
],
[
"tornadoes",
1.52,
2.15
],
[
"touch",
2.15,
2.5
],
[
"down",
2.5,
2.81
],
. . .
[
"on",
5.62,
5.74
],
[
"Sunday",
5.74,
6.34
]
],
"confidence": 0.96,
"transcript": "several tornadoes touch down as a line of
severe thunderstorms swept through Colorado on Sunday "
}
],
"final": true
}
]
}