Skip to content

Instantly share code, notes, and snippets.

@SamuelAlgheriniAI
Last active July 2, 2021 08:57
Show Gist options
  • Save SamuelAlgheriniAI/47eafe84b1029e09c78aa45f85eef561 to your computer and use it in GitHub Desktop.
Save SamuelAlgheriniAI/47eafe84b1029e09c78aa45f85eef561 to your computer and use it in GitHub Desktop.
Here there are the model, variables, folders and path creation and the extension conversion list
# Import the Wav2Vec model and processor
model = "facebook/wav2vec2-base-960h"
print("Loading model: ", model)
processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-base-960h")
model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-base-960h")
#VARIABLES
path_base = "Audio files/" #Original speech/audio files folder
sr = 16000 #Sampling rate
block_length = 30 #Speech chunk size
language = "en"
expertai_account = "your_expert.ai_email" #Your expert.ai email account
expertai_psw = "your_expert.ai_psw" #Your expert.ai psw
os.environ["EAI_USERNAME"] = expertai_account
os.environ["EAI_PASSWORD"] = expertai_psw
#Folders and Path Creation
audio_report = "Reports" #This is the folder where your report will be stored
path_converted_audio = "converted_files/" #This is the temporary folder for converted audio files
resampled_folder = "resampled_files/" #This is the folder for the resampled audio files
Path(audio_report).mkdir(parents = True, exist_ok = True) #This creates the reports folder
Path(path_converted_audio).mkdir(parents = True, exist_ok = True) #This creates the folder for converted audio files
Path(resampled_folder).mkdir(parents = True, exist_ok = True) #This creates the folder for resampled audio files
#Conversion List
extension_to_convert = ['.mp3','.mp4','.m4a','.flac','.opus'] #List of the supported files types/extensions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment