Размер видео: 1280 X 720853 X 480640 X 360
Показать панель управления
Автовоспроизведение
Автоповтор
Colab 範例程式:colab.research.google.com/drive/1daS9jIBivCuK7o_ikaau3CMQK2TwSiWv?usp=drive_link前置作業:!pip install faster_whisper nvidia-cublas-cu12參考程式碼:from faster_whisper import WhisperModelfrom google.colab import drivedrive.mount('google硬碟')trans = ""model = WhisperModel("large-v3", device="cuda", compute_type="float16")# 改成你的檔案名稱filename = "google硬碟/MyDrive/test.mp3"segs, info = model.transcribe(filename, beam_size=5, initial_prompt="臺灣的繁體中文")for i, seg in enumerate(segs, 1): startHH, startRR = divmod(seg.start, 3600) startMM, startSR = divmod(startRR*1000, 60000) startSI, startSF = divmod(startSR, 1000) endHH, endRR = divmod(seg.end, 3600) endMM, endSR = divmod(endRR*1000, 60000) endSI, endSF = divmod(endSR, 1000) trans += "%d%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d%s" % ( i, startHH, startMM, startSI, startSF, endHH, endMM, endSI, endSF, seg.text )print (trans)srtfile=open(filename+".txt", "w")srtfile.write(trans)srtfile.close()
Colab 範例程式:
colab.research.google.com/drive/1daS9jIBivCuK7o_ikaau3CMQK2TwSiWv?usp=drive_link
前置作業:
!pip install faster_whisper nvidia-cublas-cu12
參考程式碼:
from faster_whisper import WhisperModel
from google.colab import drive
drive.mount('google硬碟')
trans = ""
model = WhisperModel("large-v3", device="cuda", compute_type="float16")
# 改成你的檔案名稱
filename = "google硬碟/MyDrive/test.mp3"
segs, info = model.transcribe(filename, beam_size=5, initial_prompt="臺灣的繁體中文")
for i, seg in enumerate(segs, 1):
startHH, startRR = divmod(seg.start, 3600)
startMM, startSR = divmod(startRR*1000, 60000)
startSI, startSF = divmod(startSR, 1000)
endHH, endRR = divmod(seg.end, 3600)
endMM, endSR = divmod(endRR*1000, 60000)
endSI, endSF = divmod(endSR, 1000)
trans += "%d
%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d
%s
" % (
i,
startHH, startMM, startSI, startSF,
endHH, endMM, endSI, endSF,
seg.text
)
print (trans)
srtfile=open(filename+".txt", "w")
srtfile.write(trans)
srtfile.close()