Update README.md
Browse files
README.md
CHANGED
|
@@ -11,44 +11,78 @@ language:
|
|
| 11 |
- en
|
| 12 |
pretty_name: Speaker Identification Toolkit
|
| 13 |
---
|
| 14 |
-
# Speaker Identification Toolkit
|
| 15 |
|
| 16 |
-
This repository
|
| 17 |
|
| 18 |
## Workflow
|
| 19 |
|
| 20 |
-
1.
|
| 21 |
-
|
| 22 |
|
| 23 |
-
2.
|
| 24 |
-
|
| 25 |
|
| 26 |
-
3.
|
| 27 |
-
|
| 28 |
|
| 29 |
-
4.
|
| 30 |
-
|
| 31 |
|
| 32 |
## Dependencies
|
| 33 |
|
| 34 |
-
Ensure
|
| 35 |
|
| 36 |
-
- Python 3.8
|
| 37 |
-
|
| 38 |
-
- `ffmpeg`:
|
| 39 |
-
Install `ffmpeg` via your system's package manager or [official site](https://ffmpeg.org/).
|
| 40 |
|
| 41 |
## Configuration
|
| 42 |
|
| 43 |
-
The
|
| 44 |
|
| 45 |
- **Video Input Directory**: `base-folder/videos`
|
| 46 |
- **WAV Output Directory**: `base-folder/wavs`
|
| 47 |
- **JSON Output Directory**: `base-folder/jsons`
|
| 48 |
-
- **Speaker Mapping File**: `base-folder/scripts/
|
| 49 |
- **Processed Speaker Output Directory**: `base-folder/targeted`
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
- For `diarize-dataset.py`, set the Hugging Face API token in the script
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
- en
|
| 12 |
pretty_name: Speaker Identification Toolkit
|
| 13 |
---
|
| 14 |
+
# Speaker Identification Toolkit
|
| 15 |
|
| 16 |
+
This repository provides a comprehensive toolkit for processing audio and video files, with a focus on speaker diarization, speaker identification, audio extraction, and dataset creation. By leveraging tools like `ffmpeg`, `pyannote.audio`, and other Python libraries, the scripts enable efficient and accurate workflows for handling audio data.
|
| 17 |
|
| 18 |
## Workflow
|
| 19 |
|
| 20 |
+
### 1. Extract Audio from Videos
|
| 21 |
+
Use `dataset-creation.py` to extract English audio tracks from video files.
|
| 22 |
|
| 23 |
+
### 2. Generate Speaker Diarization Data
|
| 24 |
+
Run `diarize-dataset.py` to process the extracted WAV files and produce JSON files containing diarization data.
|
| 25 |
|
| 26 |
+
### 3. Identify Target Speaker
|
| 27 |
+
Execute `identify-speaker.py` to play audio segments from diarization files and interactively map the target speaker.
|
| 28 |
|
| 29 |
+
### 4. Isolate and Trim Target Speaker Audio
|
| 30 |
+
Use `isolate-trim.py` to extract and trim the target speaker's audio segments, preparing them for dataset creation.
|
| 31 |
|
| 32 |
## Dependencies
|
| 33 |
|
| 34 |
+
Ensure the following are installed:
|
| 35 |
|
| 36 |
+
- **Python 3.8+**
|
| 37 |
+
- **ffmpeg**: Install via your system's package manager or from the [official site](https://ffmpeg.org/).
|
|
|
|
|
|
|
| 38 |
|
| 39 |
## Configuration
|
| 40 |
|
| 41 |
+
The scripts automatically create necessary directories and pause execution for users to populate them with required data. Ensure the following directory structure is in place:
|
| 42 |
|
| 43 |
- **Video Input Directory**: `base-folder/videos`
|
| 44 |
- **WAV Output Directory**: `base-folder/wavs`
|
| 45 |
- **JSON Output Directory**: `base-folder/jsons`
|
| 46 |
+
- **Speaker Mapping File**: `base-folder/scripts/speaker_mapping.csv`
|
| 47 |
- **Processed Speaker Output Directory**: `base-folder/targeted`
|
| 48 |
|
| 49 |
+
### Notes
|
| 50 |
+
|
| 51 |
+
- For `diarize-dataset.py`, you can set the Hugging Face API token directly in the script for prompt-free operation. Replace the placeholder value in the following line:
|
| 52 |
+
```python
|
| 53 |
+
default="your_hugging_face_token"
|
| 54 |
+
```
|
| 55 |
+
- Verify directory paths and ensure all dependencies are installed to avoid runtime issues.
|
| 56 |
+
|
| 57 |
+
## Extended Description
|
| 58 |
+
|
| 59 |
+
### 1. `dataset-creation.py`
|
| 60 |
+
- **Description**: Extracts English audio tracks from video files and converts them to mono 16-bit PCM WAV format.
|
| 61 |
+
- **Key Features**:
|
| 62 |
+
- Processes video files in `.mp4` and `.mkv` formats.
|
| 63 |
+
- Automatically names output files using a sequential naming convention.
|
| 64 |
+
- **Dependencies**: `rich`, `ffmpeg`
|
| 65 |
+
|
| 66 |
+
### 2. `diarize-dataset.py`
|
| 67 |
+
- **Description**: Processes WAV files to generate JSON files containing speaker diarization data.
|
| 68 |
+
- **Key Features**:
|
| 69 |
+
- Leverages Hugging Face's `pyannote.audio` for diarization.
|
| 70 |
+
- Outputs JSON files with timestamps and speaker labels.
|
| 71 |
+
- **Dependencies**: `pyannote.audio`, `rich`
|
| 72 |
+
|
| 73 |
+
### 3. `identify-speaker.py`
|
| 74 |
+
- **Description**: Plays audio segments from diarization files to help users identify and map the target speaker for isolation.
|
| 75 |
+
- **Key Features**:
|
| 76 |
+
- Interactive selection of the target speaker.
|
| 77 |
+
- Maintains a CSV file to map diarization files to speakers.
|
| 78 |
+
- **Recommendations**:
|
| 79 |
+
- Listen to multiple segments to confirm the target speaker, as segments may contain mixed audio.
|
| 80 |
+
- If a mistake occurs, update the CSV file to correct mappings.
|
| 81 |
+
- **Dependencies**: `playsound`, `rich`, `pandas`, `ffmpeg`
|
| 82 |
+
|
| 83 |
+
### 4. `isolate-trim.py`
|
| 84 |
+
- **Description**: Extracts and trims audio segments of the target speaker, splitting them into smaller clips if necessary.
|
| 85 |
+
- **Key Features**:
|
| 86 |
+
- Isolates diarized segments for the target speaker.
|
| 87 |
+
- Trims silence and ensures clips are 30 seconds or shorter.
|
| 88 |
+
- **Dependencies**: `rich`, `pandas`, `ffmpeg`
|