Views
No views yet
git clone git@github.com:tiantiaf0627/vox-profile-release.git1conda create -n vox_profile python=3.8
2cd vox-profile-release
3pip install -e .1# Load libraries
2import torch
3import torch.nn.functional as F
4from src.model.accent.whisper_accent import WhisperWrapper
5
6# Find device
7device = torch.device("cuda") if torch.cuda.is_available() else "cpu"
8
9# Load model from Huggingface
10model = WhisperWrapper.from_pretrained("tiantiaf/whisper-large-v3-broad-accent").to(device)
11model.eval()1# Label List
2english_accent_list = [
3 'British Isles', 'North America', 'Other'
4]
5
6# Load data, here just zeros as the example
7# Our training data filters output audio shorter than 3 seconds (unreliable predictions) and longer than 15 seconds (computation limitation)
8# So you need to prepare your audio to a maximum of 15 seconds, 16kHz and mono channel
9max_audio_length = 15 * 16000
10data = torch.zeros([1, 16000]).float().to(device)[:, :max_audio_length]
11logits, embeddings = model(data, return_feature=True)
12
13# Probability and output
14accent_prob = F.softmax(logits, dim=1)
15print(english_accent_list[torch.argmax(accent_prob).detach().cpu().item()])