2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

OpenAI Whisperのタイムスタンプを出力する方法

Last updated at Posted at 2023-03-01

whisperの文字お越しでタイムスタンプ

どうやらデフォでタイムスタンプを出力させることができるようだ

model = whisper.load_model(VOICE_TYPE)
result = model.transcribe(audio_name, fp16=False, verbose=True)

ただverbose=Trueはあくまでログとして出力されるだけ。

それならモジュールを直接いじろうと思ったんですが、

どうやらresultの中身にタイムデータも入ってたことに今更気づいた・・・

{'text': 'わずもキゅうき',
'segments': [{'id': 0,
'seek': 0,
'start': 0.0,
'end': 4.5,
'text': 'わずもキゅうき',
'tokens': [50364, 9206, 18216, 4801, 15535, 824, 227, 2646, 7016, 50589],
'temperature': 1.0,
'avg_logprob': -2.158733194524592,
'compression_ratio': 0.7,
'no_speech_prob': 0.16119693219661713}],
'language': 'ja'}

引用元

model = whisper.load_model(VOICE_TYPE)
result = model.transcribe(audio_name, fp16=False)

for i in result['segments']:
    print(f"{i['start']} --> {i['end']}")
    print(i["text"])

簡単だった。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?