语音转文本
官方文档说只支持翻译成英文,实际不是如此。
translate是将其它语言翻译成英文,但是其它语言翻译成另一个语言就要用transcribe了。
实测可以用,代码如下:
from faster_whisper import WhisperModel
import time
import torch
device = "cuda"
st = time.time()
model = WhisperModel("/mnt/sda/VITSAndBigDl/BigDL/whisper_model/faster_whisper/largeV3/snapshots/", device, compute_type="int8")
end = time.time()
print('-'*20, 'fast tiny gpu load model', '-'*20)
print(f'fast tiny gpu load model time: {end-st}')
st = time.time()
segments, info = model.transcribe("/mnt/sda/VITSAndBigDl/BigDL/1.wav",language="ja",beam_size=5)
result = ''
for segment in segments:
result = result + segment.text
#print("[%.2fs -> %.2fs] %s" % (segment.start, segment.end, segment.text))
print(result)
end = time.time()
print('-'*20, 'fast tiny gpu Inference', '-'*20)
print(f'fast tiny gpu Inference time: {end-st}')
通过transcribe的language参数,能将中文转成任意语言,目前只试过转成日语和英文,效果还是有些出路,后续会跟seamless_communication对比一下效果。
测试的中文结果:
当地时间18日,《太阳报》曝光了一段凯特王妃现身的视频,称这是凯特王妃手术后的首次露面,视频画面显示,凯特王妃手提购物袋与丈夫威廉王子说笑。然而,该视频发布后,引发网友质疑,EO有表示视频中女子并不是凯特。
日语结果
当地時間18日、太陽報がカイト王妃の出身のビデオを公開しました。これはカイト王妃の手術後の初見です。視聴画面に、カイト王妃の手袋と夫、ウィリアン王子の笑いです。しかし、このビデオの発表後、ユニフォームに質問がありました。ユニフォームの女性はカイトではありません。
英语结果
On the 18th day of the local time, the Sun newspaper exposed a video of Princess Kate's appearance, saying that this was the first time the Princess Kate had shown up after the operation. The video screen shows that the Princess Kate's first shopping bag was a joke with her husband, Prince William. However, after the video was released, it aroused doubts among the netizens, saying that the woman in the video was not Kate.