Update README.md
Browse filesGUSSIED IT UP BOI!!
README.md
CHANGED
|
@@ -4,125 +4,72 @@ tags:
|
|
| 4 |
- torch
|
| 5 |
- cuda
|
| 6 |
- identifcation
|
| 7 |
-
-
|
| 8 |
-
license: cc-by-nc-nd-4.0
|
| 9 |
datasets:
|
| 10 |
- pyannote/speaker-diarization
|
| 11 |
language:
|
| 12 |
- en
|
| 13 |
-
pretty_name: Speaker
|
| 14 |
---
|
| 15 |
-
# Speaker Identification Toolkit
|
| 16 |
|
| 17 |
-
|
| 18 |
|
| 19 |
-
|
| 20 |
|
| 21 |
-
|
| 22 |
|
| 23 |
-
|
| 24 |
-
- **Key Features**:
|
| 25 |
-
- Processes video files in `.mp4` and `.mkv` formats.
|
| 26 |
-
- Outputs audio in WAV format (16kHz, mono).
|
| 27 |
-
- **Configuration**:
|
| 28 |
-
- Edit the paths for `INPUT_DIR` (video files directory) and `OUTPUT_DIR` (audio output directory) directly in the script before running.
|
| 29 |
-
- **Dependencies**: `rich`, `ffmpeg`
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
- **
|
| 36 |
-
-
|
| 37 |
-
-
|
| 38 |
-
-
|
| 39 |
-
- **Configuration**:
|
| 40 |
-
- Edit the paths for `INPUT_DIR` (WAV files directory) and `OUTPUT_DIR` (JSON output directory) directly in the script before running.
|
| 41 |
-
- Set the `HF_TOKEN` variable to your Hugging Face API token.
|
| 42 |
-
- **Dependencies**: `pyannote.audio`, `rich`
|
| 43 |
-
|
| 44 |
-
---
|
| 45 |
-
|
| 46 |
-
### 3. **identify-speaker.py**
|
| 47 |
-
|
| 48 |
-
- **Description**: Maps a target speaker from JSON diarization files by listening to audio segments interactively.
|
| 49 |
-
- **Key Features**:
|
| 50 |
-
- Plays audio segments for each speaker and allows the user to select the target speaker.
|
| 51 |
-
- Maintains a mapping of files to target speakers in a CSV file.
|
| 52 |
-
- **Configuration**:
|
| 53 |
-
- Edit the paths for `JSON_DIR` (JSON files directory), `AUDIO_DIR` (WAV files directory), and `MAPPING_FILE` (CSV file for speaker mappings) directly in the script before running.
|
| 54 |
-
- **Dependencies**: `playsound`, `rich`, `pandas`, `ffmpeg`
|
| 55 |
-
- **Recommendations**:
|
| 56 |
-
- Listen to multiple segments before confirming that it's your targeted speaker; it can sometimes have 1 second of your speaker followed by 9 seconds of your non-targeted speaker, and will throw off your dataset.
|
| 57 |
-
- If you make a mistake, stop processing, and remove the bottom most entry from the speaker\_mappings.csv file, and then re-run the script.
|
| 58 |
-
|
| 59 |
-
---
|
| 60 |
-
|
| 61 |
-
### 4. **isolate-trim.py**
|
| 62 |
-
|
| 63 |
-
- **Description**: Extracts and trims audio segments of the target speaker, splitting them into smaller clips if necessary.
|
| 64 |
-
- **Key Features**:
|
| 65 |
-
- Extracts segments for a target speaker based on the mapping CSV.
|
| 66 |
-
- Crops audio into chunks of a specified length and trims silence from each chunk.
|
| 67 |
-
- **Configuration**:
|
| 68 |
-
- Edit the paths for `JSON_DIR` (JSON files directory), `AUDIO_DIR` (WAV files directory), `MAPPING_FILE` (CSV file for speaker mappings), and `OUTPUT_DIR` (output directory for processed files) directly in the script before running.
|
| 69 |
-
- **Dependencies**: `rich`, `pandas`, `ffmpeg`
|
| 70 |
-
|
| 71 |
-
---
|
| 72 |
-
|
| 73 |
-
## Setup
|
| 74 |
-
|
| 75 |
-
### Install Dependencies
|
| 76 |
-
|
| 77 |
-
Ensure you have the following installed:
|
| 78 |
-
|
| 79 |
-
- Python 3.8+
|
| 80 |
-
- Required Python libraries:
|
| 81 |
-
```bash
|
| 82 |
-
pip install rich pandas pyannote.audio playsound
|
| 83 |
-
```
|
| 84 |
-
- `ffmpeg`:
|
| 85 |
-
Install `ffmpeg` via your system's package manager or [official site](https://ffmpeg.org/).
|
| 86 |
-
|
| 87 |
-
### Configuration
|
| 88 |
|
| 89 |
-
|
| 90 |
|
| 91 |
-
- **
|
| 92 |
-
- **
|
| 93 |
-
-
|
| 94 |
-
-
|
| 95 |
-
- **
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
-
|
| 98 |
|
| 99 |
-
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
## Workflow
|
| 107 |
-
|
| 108 |
-
1. **Extract Audio from Videos**:
|
| 109 |
-
Use `dataset-creation.py` to extract English audio tracks from video files.
|
| 110 |
|
| 111 |
-
|
| 112 |
-
|
|
|
|
| 113 |
|
| 114 |
-
|
| 115 |
-
Execute `identify-speaker.py` to map each JSON file to a target speaker interactively.
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
---
|
| 121 |
|
| 122 |
## Notes
|
| 123 |
|
| 124 |
-
- Ensure all
|
| 125 |
-
-
|
| 126 |
-
-
|
| 127 |
-
|
| 128 |
-
---
|
|
|
|
| 4 |
- torch
|
| 5 |
- cuda
|
| 6 |
- identifcation
|
| 7 |
+
license: cc-by-nc-4.0
|
|
|
|
| 8 |
datasets:
|
| 9 |
- pyannote/speaker-diarization
|
| 10 |
language:
|
| 11 |
- en
|
| 12 |
+
pretty_name: Speaker Identification Toolkit
|
| 13 |
---
|
| 14 |
+
# Speaker Identification Toolkit
|
| 15 |
|
| 16 |
+
## Overview
|
| 17 |
|
| 18 |
+
This toolkit provides a comprehensive suite of scripts for audio processing and speaker identification tasks. It includes features like video-to-audio conversion, speaker diarization, speaker isolation, and audio trimming.
|
| 19 |
|
| 20 |
+
## Scripts
|
| 21 |
|
| 22 |
+
### 1. Dataset Creation (Video to Audio Extraction)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
- **Functionality:** Extracts audio tracks from video files.
|
| 25 |
+
- **Default Directories:**
|
| 26 |
+
- Input: `videos`
|
| 27 |
+
- Output: `wavs`
|
| 28 |
+
- **Behavior:**
|
| 29 |
+
- Auto-creates `videos` and `wavs` directories in the script folder.
|
| 30 |
+
- Pauses execution to allow the user to populate the `videos` directory before processing.
|
| 31 |
+
- Processes all `.mkv` and `.mp4` files in the `videos` directory.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
+
### 2. Speaker Diarization
|
| 34 |
|
| 35 |
+
- **Functionality:** Processes audio files and generates speaker diarization metadata.
|
| 36 |
+
- **Default Directories:**
|
| 37 |
+
- Input: `wavs`
|
| 38 |
+
- Output: `jsons`
|
| 39 |
+
- **Behavior:**
|
| 40 |
+
- Auto-creates `wavs` and `jsons` directories in the script folder.
|
| 41 |
+
- Includes a prompt for the Hugging Face token with validation.
|
| 42 |
+
- Pauses execution to allow the user to populate the `wavs` directory.
|
| 43 |
+
- Generates diarization metadata in `.json` format for all `.wav` files in the `wavs` directory.
|
| 44 |
|
| 45 |
+
### 3. Speaker Isolation and Trimming
|
| 46 |
|
| 47 |
+
- **Functionality:** Isolates and trims audio segments based on speaker diarization metadata.
|
| 48 |
+
- **Default Directories:**
|
| 49 |
+
- Input JSON: `jsons`
|
| 50 |
+
- Input WAV: `wavs`
|
| 51 |
+
- Output: `targeted`
|
| 52 |
+
- **Behavior:**
|
| 53 |
+
- Auto-creates `jsons`, `wavs`, and `targeted` directories in the script folder.
|
| 54 |
+
- Pauses execution to allow the user to populate the `jsons` and `wavs` directories.
|
| 55 |
+
- Processes each `.json` file and its corresponding `.wav` file to extract and trim speaker-specific segments.
|
| 56 |
+
- Outputs trimmed audio clips in the `targeted` directory.
|
| 57 |
|
| 58 |
+
## Common Features
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
- All scripts auto-create necessary directories in the same folder as the script.
|
| 61 |
+
- Scripts pause execution at key points to allow the user to populate input directories.
|
| 62 |
+
- Rich console output for enhanced user interaction and error handling.
|
| 63 |
|
| 64 |
+
## Hugging Face Token
|
|
|
|
| 65 |
|
| 66 |
+
- Required for the Speaker Diarization script.
|
| 67 |
+
- Token validation is performed before processing.
|
| 68 |
+
- Update your token in the script or provide it at runtime when prompted.
|
|
|
|
| 69 |
|
| 70 |
## Notes
|
| 71 |
|
| 72 |
+
- Ensure all input files are placed in the correct directories before running the scripts.
|
| 73 |
+
- Output files will be saved in the corresponding output directories, which are automatically created if they do not exist.
|
| 74 |
+
- When processing multi-speakers in multi-episode files, like a TV series spanning multiple seasons, it is best practice to listen to a few segments of the speaker before confirming.
|
| 75 |
+
- If you make a mistake, stop the script and remove the bottom most line in your mappings CSV; the script will re-process it on next run.
|
|
|