Created
November 24, 2023 11:19
-
-
Save LewisGet/833198b30995e606e85b6f15c381b059 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import audeer | |
import audonnx | |
import librosa | |
import glob | |
import os | |
url = 'https://zenodo.org/record/6221127/files/w2v2-L-robust-12.6bc4a7fd-1.1.0.zip' | |
model_path = './model.zip' | |
audeer.download_url( | |
url, | |
model_path, | |
verbose=True, | |
) | |
audeer.extract_archive( | |
model_path, | |
".", | |
verbose=True, | |
) | |
model = audonnx.load(".") | |
SAMPLING_RATE = 16000 | |
files = glob.glob("output/*.wav") | |
target_folder = os.path.join(".", "kit-wav2vec2-label-16k") | |
for i, path in enumerate(files): | |
wav, _ = librosa.load(path, sr=SAMPLING_RATE, mono=True) | |
source = model(wav, SAMPLING_RATE) | |
new_name = ("%.3f-%.3f-%.3f__" % (source['logits'][0][0], source['logits'][0][1], source['logits'][0][2])) + os.path.basename(path) | |
new_path = os.path.join(target_folder, new_name) | |
os.rename(path, new_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment