Merge pull request #977 from hanasay/main

Convert audio to mono while extract speech token
This commit is contained in:
Xiang Lyu
2025-02-16 12:51:04 +08:00
committed by GitHub

View File

@@ -27,6 +27,9 @@ def single_job(utt):
audio, sample_rate = torchaudio.load(utt2wav[utt], backend='soundfile')
if sample_rate != 16000:
audio = torchaudio.transforms.Resample(orig_freq=sample_rate, new_freq=16000)(audio)
# Convert audio to mono
if audio.shape[0] > 1:
audio = audio.mean(dim=0, keepdim=True)
if audio.shape[1] / 16000 > 30:
logging.warning('do not support extract speech token for audio longer than 30s')
speech_token = []