4

使用谷歌云语音 api 时,新词准确时间戳/时间码功能似乎允许0结果中某些词的秒持续时间,这是一个示例

... { startTime: '48.800s', endTime: '48.800s', word: 'a' }, { startTime: '48.800s', endTime: '49.200s', word: 'kindly' }, ...

这是一个错误吗?

为了测试,我使用了来自音频档案“Arthur the Rat”、“USA - General mid-west Speaker (Michigan)”的剪辑。

4

2 回答 2

1

您可以使用返回的时间戳获得比秒精度更高的精度。

您可以从包含单词的结构中获取开始时间,并且可以通过以下方式输出它:

start_time.seconds + start_time.nanos * 1e-9

于 2017-09-28T22:11:39.883 回答
0

大卫安德森的回答是正确的,我只是想我会详细说明它,因为我最初认为响应只是第二精度,而不是文档描述的 100 毫秒。

截至 2018 年 7 月,向谷歌云语音 API 发送包含单词时间偏移量的请求会返回一个响应对象,其中每个单词结果response.results具有以下结构:

start_time {
  seconds: 24
  nanos: 100000000
}
end_time {
  seconds: 24
  nanos: 700000000
}
word: "of"

nanos字段允许您以 100 毫秒的精度获得开始和结束时间。所以你可以像这样获得开始和结束时间:

print(start_time.seconds + start_time.nanos * 1e-9)
print(end_time.seconds + end_time.nanos * 1e-9)

==== Output ====

24.1
24.7
于 2018-07-04T19:30:42.003 回答