You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import auditok
from paddlespeech.cli.text.infer import TextExecutor
from paddlespeech.cli.asr.infer import ASRExecutor
import sys
from tempfile import NamedTemporaryFile
import os
from pydub import AudioSegment
def dot(txt):
text_punc = TextExecutor()
result = text_punc(txt)
return result
# split returns a generator of AudioRegion objects
for root, dirs, files in os.walk(".", topdown=False):
for name in files:
if name.endswith('mp3'):
full_path = os.path.join(root, name)
print(full_path)
wav_file = full_path.replace('.mp3', '.wav')
txt_file = full_path.replace('.mp3', '.txt')
# convert to wav
sound = AudioSegment.from_mp3(full_path)
sound.export(wav_file, format="wav")
audio_regions = auditok.split(
wav_file,
min_dur=0.2, # minimum duration of a valid audio event in seconds
max_dur=20, # maximum duration of an event
max_silence=10, # maximum duration of tolerated continuous silence within an event
energy_threshold=55 # threshold of detection
)
with open(txt_file, 'w') as t:
for i, r in enumerate(audio_regions):
with NamedTemporaryFile(suffix='.wav') as f:
r.save(f.name)
asr = ASRExecutor()
raw_result = asr(audio_file=f.name, force_yes=True)
t.write(dot(raw_result))
识别过程中随着一个个音频分片的解析,眼瞅着 GPU 不断增长,从几百兆增加到 8G 最终 out of memory
General Question
因为音频文件比较大,所以我是给切分成 20s 一段再进行识别
识别过程中随着一个个音频分片的解析,眼瞅着 GPU 不断增长,从几百兆增加到 8G 最终 out of memory
试了 FLAGS_use_cuda_managed_memory 改为 true 和 false 都不行
CUDA 版本 11.2
The text was updated successfully, but these errors were encountered: