This Python script contains a class AudioProcessor
which is used for processing audio files.
This repository uses a conda environment - once you have Miniconda or Anaconda installed run the following script, replacing myenv with the name of your environment:
conda env create -f environment.yml
conda activate myenv
source activate myenv
Here's a simple example to get you started:
python
from AudioProcessor import AudioProcessor
processor = AudioProcessor(sounds_id="some_id", file_path="path/to/audio/file")
processor.mainLoop()
init(self, sounds_id, file_path)
Initializes the AudioProcessor object. get_video_id(self, video_url)
Extracts the video ID from a given URL. speaker_diarization(self)
Performs speaker diarization on the audio file. millisec(self, timeStr)
Converts a time string to milliseconds. primary_speaker(self)
Identifies the primary speaker in the audio. chunk_primary(self)
Segments the audio based on the primary speaker. transcribe_directory(self)
Transcribes all .wav files in a given directory. audio_to_audioSeg(self, t1, t2)
Extracts an audio segment between t1 and t2. mainLoop(self)
The main function that ties all the methods together.
The script uses the following environment variables:
OPENAI_API_KEY
: The API key for OpenAI.HUG_USER1
: The API key for Hugging Face.
Make sure to set these environment variables before running the script.
Feel free to open issues or PRs if you find any problems or have suggestions for improvements.