Update README.md
Browse files
README.md
CHANGED
|
@@ -1,38 +1,30 @@
|
|
| 1 |
-
|
| 2 |
-
license: cc-by-nc-sa-4.0
|
| 3 |
-
language:
|
| 4 |
-
- en
|
| 5 |
-
pretty_name: r
|
| 6 |
-
---
|
| 7 |
-
# Speaker Diarization and Identification Toolkit
|
| 8 |
|
| 9 |
-
Welcome to the **Speaker Diarization and Identification Toolkit**, a suite of tools for audio
|
| 10 |
|
| 11 |
---
|
| 12 |
|
| 13 |
-
##
|
| 14 |
|
| 15 |
-
- **Speaker Diarization**: Automatically segment and label audio by speaker
|
| 16 |
-
- **Audio Extraction**:
|
| 17 |
-
- **Speaker Identification**: Interactively map speakers
|
| 18 |
-
- **
|
| 19 |
|
| 20 |
---
|
| 21 |
|
| 22 |
-
##
|
| 23 |
-
|
| 24 |
-
To get started, ensure you have the following:
|
| 25 |
|
| 26 |
-
-
|
| 27 |
-
-
|
| 28 |
-
-
|
| 29 |
-
-
|
| 30 |
- `rich`
|
| 31 |
- `pandas`
|
| 32 |
- `pyannote.audio`
|
| 33 |
- `playsound`
|
| 34 |
|
| 35 |
-
Install
|
| 36 |
|
| 37 |
```bash
|
| 38 |
pip install -r requirements.txt
|
|
@@ -40,57 +32,36 @@ pip install -r requirements.txt
|
|
| 40 |
|
| 41 |
---
|
| 42 |
|
| 43 |
-
##
|
| 44 |
-
|
| 45 |
-
### Step 1: Clone the Repository
|
| 46 |
-
|
| 47 |
-
Clone this repository to your local machine:
|
| 48 |
-
|
| 49 |
-
```bash
|
| 50 |
-
git clone https://huggingface.co/datasets/ScottishHaze/diarization-project
|
| 51 |
-
cd diarization-project
|
| 52 |
-
```
|
| 53 |
-
|
| 54 |
-
### Step 2: Configure the Environment
|
| 55 |
-
|
| 56 |
-
1. **Install `ffmpeg`**:
|
| 57 |
-
- **Linux**: `sudo apt install ffmpeg`
|
| 58 |
-
- **MacOS**: `brew install ffmpeg`
|
| 59 |
-
- **Windows**: Download from [ffmpeg.org](https://ffmpeg.org/).
|
| 60 |
-
|
| 61 |
-
2. **Set Up a Hugging Face Token**:
|
| 62 |
-
- Create an account at [huggingface.co](https://huggingface.co/).
|
| 63 |
-
- Generate a token from your account settings.
|
| 64 |
|
| 65 |
-
|
| 66 |
-
- Create an `.env` file in the project root and add:
|
| 67 |
-
|
| 68 |
-
```env
|
| 69 |
-
HF_TOKEN=your_hugging_face_token
|
| 70 |
-
```
|
| 71 |
-
|
| 72 |
-
### Step 3: Organize Files
|
| 73 |
-
|
| 74 |
-
Use the following directory structure or customize paths interactively when running the scripts:
|
| 75 |
|
| 76 |
```plaintext
|
| 77 |
project/
|
| 78 |
-
├──
|
| 79 |
-
├──
|
| 80 |
-
├──
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
│ ├── ffmpeg-extract-audio-from-video.py
|
| 82 |
│ ├── diarization-extract-speaker-info-from-wav.py
|
| 83 |
-
│
|
| 84 |
-
├──
|
|
|
|
|
|
|
| 85 |
```
|
| 86 |
|
|
|
|
|
|
|
| 87 |
---
|
| 88 |
|
| 89 |
-
##
|
| 90 |
|
| 91 |
### 1. Extract Audio from Video
|
| 92 |
|
| 93 |
-
|
| 94 |
|
| 95 |
```bash
|
| 96 |
python ffmpeg-extract-audio-from-video.py
|
|
@@ -98,7 +69,7 @@ python ffmpeg-extract-audio-from-video.py
|
|
| 98 |
|
| 99 |
### 2. Perform Speaker Diarization
|
| 100 |
|
| 101 |
-
Run `diarization-extract-speaker-info-from-wav.py` to analyze WAV files and generate speaker segmentation JSON files:
|
| 102 |
|
| 103 |
```bash
|
| 104 |
python diarization-extract-speaker-info-from-wav.py
|
|
@@ -106,38 +77,32 @@ python diarization-extract-speaker-info-from-wav.py
|
|
| 106 |
|
| 107 |
### 3. Identify Target Speaker
|
| 108 |
|
| 109 |
-
Use `identify-single-speaker.py` to interactively identify target speakers
|
|
|
|
|
|
|
| 110 |
|
| 111 |
```bash
|
| 112 |
python identify-single-speaker.py
|
| 113 |
```
|
| 114 |
-
When doing series/multipart analysis, it is recommended you listen to a few sections before saying YES to a speaker.
|
| 115 |
-
|
| 116 |
-
---
|
| 117 |
|
| 118 |
-
|
| 119 |
|
| 120 |
-
|
| 121 |
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
|
| 126 |
---
|
| 127 |
|
| 128 |
-
##
|
| 129 |
|
| 130 |
-
This project is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
|
| 131 |
|
| 132 |
---
|
| 133 |
|
| 134 |
-
##
|
| 135 |
-
|
| 136 |
-
Gratitude goes to:
|
| 137 |
|
| 138 |
-
|
| 139 |
-
- The creators of `rich`, `pyannote.audio`, and `ffmpeg` for their indispensable tools.
|
| 140 |
-
|
| 141 |
-
---
|
| 142 |
|
| 143 |
-
Thank you for exploring this toolkit
|
|
|
|
| 1 |
+
# Speaker Diarization and Identification Toolkit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
Welcome to the **Speaker Diarization and Identification Toolkit**, a suite of tools for processing audio and identifying speakers. This repository offers Python scripts for extracting audio, performing speaker diarization, identifying speakers, and trimming segments of interest.
|
| 4 |
|
| 5 |
---
|
| 6 |
|
| 7 |
+
## Features
|
| 8 |
|
| 9 |
+
- **Speaker Diarization**: Automatically segment and label audio by speaker.
|
| 10 |
+
- **Audio Extraction**: Extract audio tracks from video files.
|
| 11 |
+
- **Speaker Identification**: Interactively map speakers using diarization data.
|
| 12 |
+
- **Segment Trimming**: Extract and trim speaker-specific audio segments.
|
| 13 |
|
| 14 |
---
|
| 15 |
|
| 16 |
+
## Requirements
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
- Python 3.8+
|
| 19 |
+
- Hugging Face token for `pyannote.audio`
|
| 20 |
+
- System dependency: `ffmpeg`
|
| 21 |
+
- Python libraries:
|
| 22 |
- `rich`
|
| 23 |
- `pandas`
|
| 24 |
- `pyannote.audio`
|
| 25 |
- `playsound`
|
| 26 |
|
| 27 |
+
Install dependencies with:
|
| 28 |
|
| 29 |
```bash
|
| 30 |
pip install -r requirements.txt
|
|
|
|
| 32 |
|
| 33 |
---
|
| 34 |
|
| 35 |
+
## Setup
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
+
### Directory Structure
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
```plaintext
|
| 40 |
project/
|
| 41 |
+
├── input/
|
| 42 |
+
│ ├── video/ # Video files
|
| 43 |
+
│ ├── audio/ # WAV files from videos
|
| 44 |
+
├── output/
|
| 45 |
+
│ ├── json/ # Diarization results
|
| 46 |
+
│ ├── audio/ # Cropped and trimmed speaker segments
|
| 47 |
+
├── scripts/
|
| 48 |
│ ├── ffmpeg-extract-audio-from-video.py
|
| 49 |
│ ├── diarization-extract-speaker-info-from-wav.py
|
| 50 |
+
│ ├── identify-single-speaker.py
|
| 51 |
+
│ ├── speaker-crop-and-trim.py
|
| 52 |
+
├── data/
|
| 53 |
+
│ └── mappings.csv # Speaker mappings
|
| 54 |
```
|
| 55 |
|
| 56 |
+
Ensure the directory structure matches the expected inputs and outputs for each script.
|
| 57 |
+
|
| 58 |
---
|
| 59 |
|
| 60 |
+
## Usage
|
| 61 |
|
| 62 |
### 1. Extract Audio from Video
|
| 63 |
|
| 64 |
+
Run the `ffmpeg-extract-audio-from-video.py` script to extract audio tracks from video files:
|
| 65 |
|
| 66 |
```bash
|
| 67 |
python ffmpeg-extract-audio-from-video.py
|
|
|
|
| 69 |
|
| 70 |
### 2. Perform Speaker Diarization
|
| 71 |
|
| 72 |
+
Run the `diarization-extract-speaker-info-from-wav.py` script to analyze WAV files and generate speaker segmentation JSON files:
|
| 73 |
|
| 74 |
```bash
|
| 75 |
python diarization-extract-speaker-info-from-wav.py
|
|
|
|
| 77 |
|
| 78 |
### 3. Identify Target Speaker
|
| 79 |
|
| 80 |
+
Use the `identify-single-speaker.py` script to interactively identify and map target speakers. For multiple parts / TV series
|
| 81 |
+
it is recommended you listen to multiple segments of each speaker before identifying "Y". Sometimes after diarization, the targeted
|
| 82 |
+
speaker can be blended in with other speakers.
|
| 83 |
|
| 84 |
```bash
|
| 85 |
python identify-single-speaker.py
|
| 86 |
```
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
+
### 4. Crop and Trim Speaker Segments
|
| 89 |
|
| 90 |
+
Run the `speaker-crop-and-trim.py` script to extract, crop, and trim audio segments for identified speakers:
|
| 91 |
|
| 92 |
+
```bash
|
| 93 |
+
python speaker-crop-and-trim.py
|
| 94 |
+
```
|
| 95 |
|
| 96 |
---
|
| 97 |
|
| 98 |
+
## License
|
| 99 |
|
| 100 |
+
This project is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0). Refer to the [LICENSE](LICENSE) file for details.
|
| 101 |
|
| 102 |
---
|
| 103 |
|
| 104 |
+
## Acknowledgments
|
|
|
|
|
|
|
| 105 |
|
| 106 |
+
Gratitude to [Hugging Face](https://huggingface.co/) and the developers of `rich`, `pyannote.audio`, and `ffmpeg` for their invaluable tools.
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
+
Thank you for exploring this toolkit!
|