Adding the first version of data
Browse filesSigned-off-by: taejinp <[email protected]>
This view is limited to 50 files because it contains too many changes.
See raw diff
- run_samples_acous.py +553 -0
- utt_samples/A_text4_af_heart.wav +3 -0
- utt_samples/B_text8_af_aoede.wav +3 -0
- utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede.rttm +1 -0
- utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede.wav +3 -0
- utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede_B_text11_af_aoede_Ac_Bc.rttm +2 -0
- utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede_B_text11_af_aoede_Ac_Bc.wav +3 -0
- utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede_B_text11_af_aoede_Ac_Bp.rttm +2 -0
- utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede_B_text11_af_aoede_Ac_Bp.wav +3 -0
- utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede_B_text11_af_aoede_Ap_Bc.rttm +2 -0
- utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede_B_text11_af_aoede_Ap_Bc.wav +3 -0
- utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede_B_text11_af_aoede_Ap_Bp.rttm +2 -0
- utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede_B_text11_af_aoede_Ap_Bp.wav +3 -0
- utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede_R_Room088-00049_N_simroom3_9.rttm +1 -0
- utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede_R_Room088-00049_N_simroom3_9.wav +3 -0
- utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/B_text11_af_aoede.rttm +1 -0
- utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/B_text11_af_aoede.wav +3 -0
- utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/B_text11_af_aoede_R_Room088-00049_N_simroom3_9.rttm +1 -0
- utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/B_text11_af_aoede_R_Room088-00049_N_simroom3_9.wav +3 -0
- utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella.rttm +1 -0
- utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella.wav +3 -0
- utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella_B_text11_af_bella_Ac_Bc.rttm +2 -0
- utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella_B_text11_af_bella_Ac_Bc.wav +3 -0
- utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella_B_text11_af_bella_Ac_Bp.rttm +2 -0
- utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella_B_text11_af_bella_Ac_Bp.wav +3 -0
- utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella_B_text11_af_bella_Ap_Bc.rttm +2 -0
- utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella_B_text11_af_bella_Ap_Bc.wav +3 -0
- utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella_B_text11_af_bella_Ap_Bp.rttm +2 -0
- utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella_B_text11_af_bella_Ap_Bp.wav +3 -0
- utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella_R_Room073-00024_N_smallroom2_7.rttm +1 -0
- utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella_R_Room073-00024_N_smallroom2_7.wav +3 -0
- utt_samples_matched/A_text00_af_bella_B_text11_af_bella/B_text11_af_bella.rttm +1 -0
- utt_samples_matched/A_text00_af_bella_B_text11_af_bella/B_text11_af_bella.wav +3 -0
- utt_samples_matched/A_text00_af_bella_B_text11_af_bella/B_text11_af_bella_R_Room073-00024_N_smallroom2_7.rttm +1 -0
- utt_samples_matched/A_text00_af_bella_B_text11_af_bella/B_text11_af_bella_R_Room073-00024_N_smallroom2_7.wav +3 -0
- utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart.rttm +1 -0
- utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart.wav +3 -0
- utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart_B_text11_af_heart_Ac_Bc.rttm +2 -0
- utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart_B_text11_af_heart_Ac_Bc.wav +3 -0
- utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart_B_text11_af_heart_Ac_Bp.rttm +2 -0
- utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart_B_text11_af_heart_Ac_Bp.wav +3 -0
- utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart_B_text11_af_heart_Ap_Bc.rttm +2 -0
- utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart_B_text11_af_heart_Ap_Bc.wav +3 -0
- utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart_B_text11_af_heart_Ap_Bp.rttm +2 -0
- utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart_B_text11_af_heart_Ap_Bp.wav +3 -0
- utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart_R_Room037-00049_N_largeroom1_3.rttm +1 -0
- utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart_R_Room037-00049_N_largeroom1_3.wav +3 -0
- utt_samples_matched/A_text00_af_heart_B_text11_af_heart/B_text11_af_heart.rttm +1 -0
- utt_samples_matched/A_text00_af_heart_B_text11_af_heart/B_text11_af_heart.wav +3 -0
- utt_samples_matched/A_text00_af_heart_B_text11_af_heart/B_text11_af_heart_R_Room037-00049_N_largeroom1_3.rttm +1 -0
run_samples_acous.py
ADDED
@@ -0,0 +1,553 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
# 3️⃣ Initalize a pipeline
|
3 |
+
from kokoro import KPipeline
|
4 |
+
from IPython.display import display, Audio
|
5 |
+
import soundfile as sf
|
6 |
+
import torch
|
7 |
+
import numpy as np
|
8 |
+
from scipy import signal
|
9 |
+
import os
|
10 |
+
import json
|
11 |
+
from pathlib import Path
|
12 |
+
from tqdm import tqdm
|
13 |
+
# 🇺🇸 'a' => American English, 🇬🇧 'b' => British English
|
14 |
+
# 🇪🇸 'e' => Spanish es
|
15 |
+
# 🇫🇷 'f' => French fr-fr
|
16 |
+
# 🇮🇳 'h' => Hindi hi
|
17 |
+
# 🇮🇹 'i' => Italian it
|
18 |
+
# 🇯🇵 'j' => Japanese: pip install misaki[ja]
|
19 |
+
# 🇧🇷 'p' => Brazilian Portuguese pt-br
|
20 |
+
# 🇨🇳 'z' => Mandarin Chinese: pip install misaki[zh]
|
21 |
+
|
22 |
+
|
23 |
+
# Create random generators for RIR and white noise files
|
24 |
+
import random
|
25 |
+
random.seed(42)
|
26 |
+
|
27 |
+
|
28 |
+
def get_random_rir_generator(simulated_rirs_dict):
|
29 |
+
"""Generator that yields random RIR file paths from the simulated_rirs_dict"""
|
30 |
+
rir_paths = list(simulated_rirs_dict.keys())
|
31 |
+
while True:
|
32 |
+
yield random.choice(rir_paths)
|
33 |
+
|
34 |
+
def get_random_white_noise_generator(white_noise_dict):
|
35 |
+
"""Generator that yields random white noise file paths from the white_noise_dict"""
|
36 |
+
white_noise_paths = list(white_noise_dict.keys())
|
37 |
+
while True:
|
38 |
+
yield random.choice(white_noise_paths)
|
39 |
+
|
40 |
+
|
41 |
+
def load_manifest_file(manifest_path):
|
42 |
+
"""
|
43 |
+
Load a JSONL manifest file into a dictionary.
|
44 |
+
|
45 |
+
Args:
|
46 |
+
manifest_path (str): Path to the JSONL manifest file
|
47 |
+
|
48 |
+
Returns:
|
49 |
+
dict: Dictionary with audio filepath as key and metadata as value
|
50 |
+
"""
|
51 |
+
manifest_dict = {}
|
52 |
+
|
53 |
+
try:
|
54 |
+
with open(manifest_path, 'r') as f:
|
55 |
+
for line_num, line in enumerate(f, 1):
|
56 |
+
line = line.strip()
|
57 |
+
if line: # Skip empty lines
|
58 |
+
try:
|
59 |
+
entry = json.loads(line)
|
60 |
+
audio_filepath = entry.get('audio_filepath')
|
61 |
+
if audio_filepath:
|
62 |
+
manifest_dict[audio_filepath] = entry
|
63 |
+
else:
|
64 |
+
print(f"Warning: Line {line_num} missing audio_filepath")
|
65 |
+
except json.JSONDecodeError as e:
|
66 |
+
print(f"Warning: Invalid JSON on line {line_num}: {e}")
|
67 |
+
continue
|
68 |
+
|
69 |
+
print(f"Successfully loaded {len(manifest_dict)} entries from {manifest_path}")
|
70 |
+
return manifest_dict
|
71 |
+
|
72 |
+
except FileNotFoundError:
|
73 |
+
print(f"Error: Manifest file not found: {manifest_path}")
|
74 |
+
return {}
|
75 |
+
except Exception as e:
|
76 |
+
print(f"Error loading manifest file {manifest_path}: {e}")
|
77 |
+
return {}
|
78 |
+
|
79 |
+
def load_rirs_manifests(simulated_rirs_path="/disk_a_nvd/datasets/RIRS_NOISES/simulated_rirs.json",
|
80 |
+
white_noise_path="/disk_a_nvd/datasets/RIRS_NOISES/white_noise.json"
|
81 |
+
):
|
82 |
+
"""
|
83 |
+
Load both RIRS_NOISES manifest files into dictionaries.
|
84 |
+
|
85 |
+
Args:
|
86 |
+
simulated_rirs_path (str): Path to the simulated RIRs manifest file
|
87 |
+
white_noise_path (str): Path to the white noise manifest file
|
88 |
+
|
89 |
+
Returns:
|
90 |
+
tuple: (simulated_rirs_dict, white_noise_dict)
|
91 |
+
"""
|
92 |
+
simulated_rirs_dict = load_manifest_file(simulated_rirs_path)
|
93 |
+
white_noise_dict = load_manifest_file(white_noise_path)
|
94 |
+
|
95 |
+
return simulated_rirs_dict, white_noise_dict
|
96 |
+
|
97 |
+
def apply_perturb(input_wav_file_path, rir_wav_path, noise_wav_path, noise_scale_factor=3.0, output_sr=16000):
|
98 |
+
"""
|
99 |
+
Apply Room Impulse Response (RIR) and optionally noise to an audio file.
|
100 |
+
|
101 |
+
Args:
|
102 |
+
input_wav_file_path (str): Path to the input audio file
|
103 |
+
rir_wav_path (str): Path to the RIR file
|
104 |
+
noise_wav_path (str, optional): Path to the noise file
|
105 |
+
|
106 |
+
Returns:
|
107 |
+
str: Path to the output file with RIR and noise applied
|
108 |
+
"""
|
109 |
+
# Load input audio and use first channel if multichannel
|
110 |
+
input_audio, input_sr = sf.read(input_wav_file_path)
|
111 |
+
if len(input_audio.shape) > 1:
|
112 |
+
input_audio = input_audio[:, 0]
|
113 |
+
|
114 |
+
# Load RIR and use first channel if multichannel
|
115 |
+
rir_audio, rir_sr = sf.read(rir_wav_path)
|
116 |
+
if len(rir_audio.shape) > 1:
|
117 |
+
rir_audio = rir_audio[:, 0]
|
118 |
+
|
119 |
+
# Ensure both audio files have the same sample rate
|
120 |
+
if input_sr != rir_sr:
|
121 |
+
print(f"Warning: Sample rate mismatch. Input: {input_sr}Hz, RIR: {rir_sr}Hz")
|
122 |
+
# Resample RIR to match input sample rate if needed
|
123 |
+
if rir_sr != input_sr:
|
124 |
+
# Simple resampling - in production you might want to use librosa.resample
|
125 |
+
rir_audio = signal.resample(rir_audio, int(len(rir_audio) * input_sr / rir_sr))
|
126 |
+
|
127 |
+
# Apply RIR convolution
|
128 |
+
output_audio = signal.convolve(input_audio, rir_audio, mode='full')
|
129 |
+
|
130 |
+
# Apply noise if provided
|
131 |
+
if noise_wav_path is not None:
|
132 |
+
try:
|
133 |
+
# Load noise audio and use first channel if multichannel
|
134 |
+
noise_audio, noise_sr = sf.read(noise_wav_path)
|
135 |
+
if len(noise_audio.shape) > 1:
|
136 |
+
noise_audio = noise_audio[:, 0]
|
137 |
+
|
138 |
+
# Resample noise if needed
|
139 |
+
if noise_sr != input_sr:
|
140 |
+
noise_audio = signal.resample(noise_audio, int(len(noise_audio) * input_sr / noise_sr))
|
141 |
+
|
142 |
+
# Ensure noise is the same length as output_audio
|
143 |
+
if len(noise_audio) < len(output_audio):
|
144 |
+
# Repeat noise if it's shorter
|
145 |
+
repeats_needed = int(np.ceil(len(output_audio) / len(noise_audio)))
|
146 |
+
noise_audio = np.tile(noise_audio, repeats_needed)
|
147 |
+
|
148 |
+
# Trim noise to match output_audio length
|
149 |
+
noise_audio = noise_audio[:len(output_audio)]
|
150 |
+
|
151 |
+
# Add noise to output audio
|
152 |
+
noise_scale = noise_scale_factor * np.max(np.abs(output_audio))
|
153 |
+
output_audio += noise_scale * noise_audio
|
154 |
+
|
155 |
+
|
156 |
+
except Exception as e:
|
157 |
+
raise SyntaxError(f"Error: Could not apply noise from {noise_wav_path}: {e}")
|
158 |
+
|
159 |
+
# Normalize the output audio
|
160 |
+
max_val = np.max(np.abs(output_audio))
|
161 |
+
if max_val > 0:
|
162 |
+
output_audio = output_audio / max_val * 0.95 # Scale to 95% to avoid clipping
|
163 |
+
|
164 |
+
# Create output filename with RIR and noise information
|
165 |
+
input_path = Path(input_wav_file_path)
|
166 |
+
rir_path = Path(rir_wav_path)
|
167 |
+
rir_name = rir_path.stem # Get filename without extension
|
168 |
+
|
169 |
+
if noise_wav_path is not None:
|
170 |
+
noise_path = Path(noise_wav_path)
|
171 |
+
noise_name = "_".join(noise_path.stem.split("_")[-2:])
|
172 |
+
output_filename = f"{input_path.stem}_R_{rir_name}_N_{noise_name}{input_path.suffix}"
|
173 |
+
else:
|
174 |
+
output_filename = f"{input_path.stem}_R_{rir_name}{input_path.suffix}"
|
175 |
+
|
176 |
+
|
177 |
+
# Make this absolute path
|
178 |
+
output_path = f"{input_path.parent}/{output_filename}"
|
179 |
+
output_path = os.path.abspath(output_path)
|
180 |
+
|
181 |
+
# Save the processed audio
|
182 |
+
# Resample to output_sr
|
183 |
+
output_audio = signal.resample(output_audio, int(len(output_audio) * output_sr / input_sr))
|
184 |
+
sf.write(str(output_path), output_audio, output_sr)
|
185 |
+
|
186 |
+
# print(f"Perturbation applied successfully. Output saved as: {output_path}")
|
187 |
+
|
188 |
+
return output_audio, str(output_path)
|
189 |
+
|
190 |
+
|
191 |
+
def concat_with_fo_fi(audio1, audio2, sr=16000, transition_time=0.2):
|
192 |
+
"""
|
193 |
+
Concatenate two audio arrays with fade out on the first and fade in on the second.
|
194 |
+
|
195 |
+
Args:
|
196 |
+
audio1 (np.array): First audio array
|
197 |
+
audio2 (np.array): Second audio array
|
198 |
+
sr (int): Sample rate
|
199 |
+
transition_time (float): Transition time in seconds
|
200 |
+
|
201 |
+
Returns:
|
202 |
+
np.array: Concatenated audio with smooth transition
|
203 |
+
"""
|
204 |
+
# Calculate transition samples
|
205 |
+
transition_samples = int(transition_time * sr)
|
206 |
+
|
207 |
+
# Ensure transition_samples doesn't exceed audio length
|
208 |
+
transition_samples = min(transition_samples, len(audio1), len(audio2))
|
209 |
+
|
210 |
+
# Create fade out for audio1 (last transition_samples)
|
211 |
+
fade_out = np.linspace(1.0, 0.0, transition_samples)
|
212 |
+
audio1_faded = audio1.copy()
|
213 |
+
audio1_faded[-transition_samples:] *= fade_out
|
214 |
+
|
215 |
+
# Create fade in for audio2 (first transition_samples)
|
216 |
+
fade_in = np.linspace(0.0, 1.0, transition_samples)
|
217 |
+
audio2_faded = audio2.copy()
|
218 |
+
audio2_faded[:transition_samples] *= fade_in
|
219 |
+
|
220 |
+
# Concatenate the audio
|
221 |
+
# audio1 without the last transition_samples + audio2 without the first transition_samples
|
222 |
+
audio1_part = audio1_faded[:-transition_samples]
|
223 |
+
audio2_part = audio2_faded[transition_samples:]
|
224 |
+
|
225 |
+
# Concatenate
|
226 |
+
concatenated = np.concatenate([audio1_part, audio2_part])
|
227 |
+
|
228 |
+
return concatenated
|
229 |
+
|
230 |
+
|
231 |
+
def get_manifest_entry(audio_filepath, text, label="infer", num_speakers=1, rttm_filepath=None, uem_filepath=None, ctm_filepath=None):
|
232 |
+
# {"audio_filepath": "/disk_a_nvd/datasets/RIRS_NOISES/real_rirs_isotropic_noises/RVB2014_type1_noise_largeroom1_3.wav", "offset": 0, "duration": null, "label": "infer", "text": "-", "num_speakers": null, "rttm_filepath": null, "uem_filepath": null, "ctm_filepath": null}
|
233 |
+
# Get the duration of the audio file
|
234 |
+
audio_duration = sf.SoundFile(audio_filepath).frames / sf.SoundFile(audio_filepath).samplerate
|
235 |
+
duration_in_seconds = round(audio_duration, 2)
|
236 |
+
|
237 |
+
|
238 |
+
# make all the paths absolute
|
239 |
+
audio_filepath = os.path.abspath(audio_filepath)
|
240 |
+
rttm_filepath = os.path.abspath(rttm_filepath)
|
241 |
+
|
242 |
+
return {
|
243 |
+
"audio_filepath": audio_filepath,
|
244 |
+
"offset": 0,
|
245 |
+
"duration": duration_in_seconds,
|
246 |
+
"label": label,
|
247 |
+
"text": text,
|
248 |
+
"num_speakers": num_speakers,
|
249 |
+
"rttm_filepath": rttm_filepath,
|
250 |
+
"uem_filepath": uem_filepath,
|
251 |
+
"ctm_filepath": ctm_filepath,
|
252 |
+
"source_lang": "en",
|
253 |
+
"target_lang": "en",
|
254 |
+
"pnc": "no",
|
255 |
+
"timestamp": "no",
|
256 |
+
}
|
257 |
+
|
258 |
+
def make_single_speaker_rttm(uniq_id, audio_filepath, rttm_filepath, speaker_name):
|
259 |
+
"""
|
260 |
+
SPEAKER {uniq_id} 0 {duration:.3f} <NA> <NA> {speaker_name} <NA> <NA>
|
261 |
+
"""
|
262 |
+
# Load audio file
|
263 |
+
audio, sr = sf.read(audio_filepath)
|
264 |
+
duration = len(audio) / sr
|
265 |
+
|
266 |
+
# Create RTTM file
|
267 |
+
with open(rttm_filepath, 'w') as f:
|
268 |
+
f.write(f"SPEAKER {uniq_id} 0.0 {duration:.3f} <NA> <NA> {speaker_name} <NA> <NA>\n")
|
269 |
+
|
270 |
+
def make_two_speaker_rttm(uniq_id, audio_filepath_A, audio_filepath_B, rttm_filepath, speaker_A, speaker_B):
|
271 |
+
"""
|
272 |
+
# SPEAKER iapb 0 0 3.26 <NA> <NA> speaker_A <NA> <NA>
|
273 |
+
# SPEAKER iapb 0 3.26 0.42 <NA> <NA> speaker_B <NA> <NA>
|
274 |
+
"""
|
275 |
+
# Load audio file
|
276 |
+
audio_A, sr = sf.read(audio_filepath_A)
|
277 |
+
duration_A = len(audio_A) / sr
|
278 |
+
|
279 |
+
audio_B, sr = sf.read(audio_filepath_B)
|
280 |
+
duration_B = len(audio_B) / sr
|
281 |
+
|
282 |
+
# Create RTTM file
|
283 |
+
with open(rttm_filepath, 'w') as f:
|
284 |
+
# for i in range(num_speakers):
|
285 |
+
f.write(f"SPEAKER {uniq_id} 1 0.0 {duration_A:.3f} <NA> <NA> {speaker_A} <NA> <NA>\n")
|
286 |
+
f.write(f"SPEAKER {uniq_id} 1 {duration_A:.3f} {duration_B:.3f} <NA> <NA> {speaker_B} <NA> <NA>\n")
|
287 |
+
|
288 |
+
|
289 |
+
pipeline = KPipeline(lang_code='a') # <= make sure lang_code matches voice, reference above.
|
290 |
+
|
291 |
+
# This text is for demonstration purposes only, unseen during training
|
292 |
+
# text = '''
|
293 |
+
# The sky above the port was the color of television, tuned to a dead channel.
|
294 |
+
# "It's not like I'm using," Case heard someone say, as he shouldered his way through the crowd around the door of the Chat. "It's like my body's developed this massive drug deficiency."
|
295 |
+
# It was a Sprawl voice and a Sprawl joke. The Chatsubo was a bar for professional expatriates; you could drink there for a week and never hear two words in Japanese.
|
296 |
+
|
297 |
+
# These were to have an enormous impact, not only because they were associated with Constantine, but also because, as in so many other areas, the decisions taken by Constantine (or in his name) were to have great significance for centuries to come. One of the main issues was the shape that Christian churches were to take, since there was not, apparently, a tradition of monumental church buildings when Constantine decided to help the Christian church build a series of truly spectacular structures. The main form that these churches took was that of the basilica, a multipurpose rectangular structure, based ultimately on the earlier Greek stoa, which could be found in most of the great cities of the empire. Christianity, unlike classical polytheism, needed a large interior space for the celebration of its religious services, and the basilica aptly filled that need. We naturally do not know the degree to which the emperor was involved in the design of new churches, but it is tempting to connect this with the secular basilica that Constantine completed in the Roman forum (the so-called Basilica of Maxentius) and the one he probably built in Trier, in connection with his residence in the city at a time when he was still caesar.
|
298 |
+
|
299 |
+
# [Kokoro](/kˈOkəɹO/) is an open-weight TTS model with 82 million parameters. Despite its lightweight architecture, it delivers comparable quality to larger models while being significantly faster and more cost-efficient. With Apache-licensed weights, [Kokoro](/kˈOkəɹO/) can be deployed anywhere from production environments to personal projects.
|
300 |
+
# '''
|
301 |
+
# text = '「もしおれがただ偶然、そしてこうしようというつもりでなくここに立っているのなら、ちょっとばかり絶望するところだな」と、そんなことが彼の頭に思い浮かんだ。'
|
302 |
+
# text = '中國人民不信邪也不怕邪,不惹事也不怕事,任何外國不要指望我們會拿自己的核心利益做交易,不要指望我們會吞下損害我國主權、安全、發展利益的苦果!'
|
303 |
+
# text = 'Los partidos políticos tradicionales compiten con los populismos y los movimientos asamblearios.'
|
304 |
+
# text = 'Le dromadaire resplendissant déambulait tranquillement dans les méandres en mastiquant de petites feuilles vernissées.'
|
305 |
+
# text = 'ट्रांसपोर्टरों की हड़ताल लगातार पांचवें दिन जारी, दिसंबर से इलेक्ट्रॉनिक टोल कलेक्शनल सिस्टम'
|
306 |
+
# text = "Allora cominciava l'insonnia, o un dormiveglia peggiore dell'insonnia, che talvolta assumeva i caratteri dell'incubo."
|
307 |
+
# text = 'Elabora relatórios de acompanhamento cronológico para as diferentes unidades do Departamento que propõem contratos.'
|
308 |
+
text_list_A = [
|
309 |
+
"She sells sea shells by the seashore while subtly shifting sapphire souvenirs.",
|
310 |
+
"The anthropologist's anecdote about antediluvian artifacts was astonishingly ambiguous.",
|
311 |
+
"I scream, you scream, we all scream for ice cream, especially when it's free.",
|
312 |
+
"Their heir apparently inherited an eerily empty estate.",
|
313 |
+
"Can you can a can as a canner can can a can?",
|
314 |
+
"The lead violinist led the lead singer through a leaden performance.",
|
315 |
+
"Fred fed Ted bread, and Ted fed Fred bread.",
|
316 |
+
"I thought a thought but the thought I thought wasn't the thought I thought I thought.",
|
317 |
+
"How can a clam cram in a clean cream can?",
|
318 |
+
"Six slippery snails slid slowly seaward.",
|
319 |
+
"I slit the sheet, the sheet I slit, and on the slitted sheet I sit.",
|
320 |
+
"Lesser leather never weathered wetter weather better."
|
321 |
+
]
|
322 |
+
text_list_B = text_list_A[::-1]
|
323 |
+
|
324 |
+
# Filtered speaker list - Top 20 speakers with gender balance (10 female, 10 male)
|
325 |
+
# Selected based on quality grades: A, A-, B, B-, C+
|
326 |
+
speaker_list = [
|
327 |
+
# Female speakers (10) - American English
|
328 |
+
"af_heart", # A grade
|
329 |
+
"af_bella", # A- grade
|
330 |
+
"af_nicole", # B- grade
|
331 |
+
"af_aoede", # C+ grade
|
332 |
+
"af_kore", # C+ grade
|
333 |
+
"af_sarah", # C+ grade
|
334 |
+
# Female speakers (2) - British English
|
335 |
+
"bf_emma", # B- grade
|
336 |
+
"bf_isabella", # C grade
|
337 |
+
# Male speakers (8) - American English
|
338 |
+
"am_fenrir", # C+ grade
|
339 |
+
"am_michael", # C+ grade
|
340 |
+
"am_puck", # C+ grade
|
341 |
+
"am_echo", # D grade (included for balance)
|
342 |
+
"am_eric", # D grade (included for balance)
|
343 |
+
"am_liam", # D grade (included for balance)
|
344 |
+
# Male speakers (2) - British English
|
345 |
+
"bm_fable", # B grade
|
346 |
+
"bm_george", # B grade
|
347 |
+
]
|
348 |
+
|
349 |
+
|
350 |
+
# RIR file path
|
351 |
+
simulated_rir_manifest_path = "/disk_a_nvd/datasets/RIRS_NOISES/simulated_rirs.json"
|
352 |
+
white_noise_manifest_path = "/disk_a_nvd/datasets/RIRS_NOISES/white_noise.json"
|
353 |
+
|
354 |
+
simulated_rirs_dict, white_noise_dict = load_rirs_manifests(simulated_rir_manifest_path, white_noise_manifest_path)
|
355 |
+
|
356 |
+
# Initialize generators
|
357 |
+
rir_generator = get_random_rir_generator(simulated_rirs_dict)
|
358 |
+
white_noise_generator = get_random_white_noise_generator(white_noise_dict)
|
359 |
+
|
360 |
+
speech_speed = 1.3
|
361 |
+
|
362 |
+
base_folder_name = "utt_samples"
|
363 |
+
shift_left = 15
|
364 |
+
speaker_list_A = speaker_list
|
365 |
+
speaker_list_B = speaker_list_A[shift_left:] + speaker_list_A[:shift_left]
|
366 |
+
|
367 |
+
# matched_speaker_mode = True
|
368 |
+
matched_speaker_mode = False
|
369 |
+
folder_name = base_folder_name + "_matched" if matched_speaker_mode else base_folder_name + "_unmatched"
|
370 |
+
|
371 |
+
# If path does not exist, create it (exists okay)
|
372 |
+
os.makedirs(folder_name, exist_ok=True)
|
373 |
+
|
374 |
+
if matched_speaker_mode:
|
375 |
+
num_speakers = 1
|
376 |
+
else:
|
377 |
+
num_speakers = 2
|
378 |
+
|
379 |
+
|
380 |
+
indiv_text_manifest_clean = []
|
381 |
+
indiv_text_manifest_clean_perturbed = []
|
382 |
+
indiv_text_manifest_perturbed_clean = []
|
383 |
+
indiv_text_manifest_perturbed = []
|
384 |
+
pair_text_manifest_Ac_Bc = []
|
385 |
+
pair_text_manifest_Ac_Bp = []
|
386 |
+
pair_text_manifest_Ap_Bc = []
|
387 |
+
pair_text_manifest_Ap_Bp = []
|
388 |
+
|
389 |
+
count = 0
|
390 |
+
total_speakers = len(speaker_list_A) # Since we break after count > 2, max is 3
|
391 |
+
for speaker_A, speaker_B in tqdm(zip(speaker_list_A, speaker_list_B), total=total_speakers, desc="Processing speakers"):
|
392 |
+
|
393 |
+
# if count > 2:
|
394 |
+
# break
|
395 |
+
|
396 |
+
count += 1
|
397 |
+
|
398 |
+
if matched_speaker_mode:
|
399 |
+
speaker_B = speaker_A
|
400 |
+
|
401 |
+
generator_A = pipeline(
|
402 |
+
text_list_A, voice=speaker_A, # <= use current speaker from loop
|
403 |
+
speed=speech_speed, split_pattern=r'\n+'
|
404 |
+
)
|
405 |
+
generator_B = pipeline(
|
406 |
+
text_list_B, voice=speaker_B, # <= use current speaker from loop
|
407 |
+
speed=speech_speed, split_pattern=r'\n+'
|
408 |
+
)
|
409 |
+
text_data_size = len(text_list_A)
|
410 |
+
text_data_size_B = len(text_list_B)
|
411 |
+
assert text_data_size == text_data_size_B, "Text data size mismatch"
|
412 |
+
|
413 |
+
for idx, ((gs_text_A, ps_A, audio_A), (gs_text_B, ps_B, audio_B)) in tqdm(enumerate(zip(generator_A, generator_B)), total=text_data_size, desc=f"Processing {speaker_A} vs {speaker_B}", leave=False):
|
414 |
+
|
415 |
+
# zfill the indices to 2 digits
|
416 |
+
A_idx = idx
|
417 |
+
B_idx = str(text_data_size - A_idx - 1).zfill(2)
|
418 |
+
A_idx = str(A_idx).zfill(2)
|
419 |
+
|
420 |
+
# Get random RIR and white noise file paths
|
421 |
+
rir_wav_path = next(rir_generator)
|
422 |
+
noise_wav_path = next(white_noise_generator)
|
423 |
+
|
424 |
+
# print(f"Using RIR: {rir_wav_path}")
|
425 |
+
# print(f"Using white noise: {noise_wav_path}")
|
426 |
+
|
427 |
+
sub_folder_name = f"A_text{A_idx}_{speaker_A}_B_text{B_idx}_{speaker_B}"
|
428 |
+
|
429 |
+
os.makedirs(f"{folder_name}/{sub_folder_name}", exist_ok=True)
|
430 |
+
|
431 |
+
# Process audio from generator A
|
432 |
+
uniq_id_a = f"A_text{A_idx}_{speaker_A}"
|
433 |
+
original_filename_A = f'{folder_name}/{sub_folder_name}/{uniq_id_a}.wav'
|
434 |
+
# Resample audio to 16000 Hz
|
435 |
+
audio_A_16k = signal.resample(audio_A, int(len(audio_A) * 16000 / 24000))
|
436 |
+
sf.write(original_filename_A, audio_A_16k, 16000)
|
437 |
+
|
438 |
+
# Apply RIR and noise to the generated audio A
|
439 |
+
try:
|
440 |
+
perturbed_audio_A_16k, perturbed_audio_A_16k_path = apply_perturb(original_filename_A, rir_wav_path, noise_wav_path)
|
441 |
+
except Exception as e:
|
442 |
+
print(f"Error applying perturbation to {original_filename_A}: {e}")
|
443 |
+
|
444 |
+
# Process audio from generator B
|
445 |
+
uniq_id_b = f"B_text{B_idx}_{speaker_B}"
|
446 |
+
original_filename_B = f'{folder_name}/{sub_folder_name}/{uniq_id_b}.wav'
|
447 |
+
audio_B_16k = signal.resample(audio_B, int(len(audio_B) * 16000 / 24000))
|
448 |
+
sf.write(original_filename_B, audio_B_16k, 16000)
|
449 |
+
|
450 |
+
# Apply RIR and noise to the generated audio B
|
451 |
+
try:
|
452 |
+
perturbed_audio_B_16k, perturbed_audio_B_16k_path = apply_perturb(original_filename_B, rir_wav_path, noise_wav_path)
|
453 |
+
except Exception as e:
|
454 |
+
print(f"Error applying perturbation to {original_filename_B}: {e}")
|
455 |
+
|
456 |
+
pair_gt_text = f"{gs_text_A} {gs_text_B}"
|
457 |
+
uniq_id_pair = f"{uniq_id_a}_{uniq_id_b}"
|
458 |
+
uniq_id_pair_Ac_Bc = f"{uniq_id_a}_Ac_Bc"
|
459 |
+
uniq_id_pair_Ac_Bp = f"{uniq_id_a}_Ac_Bp"
|
460 |
+
uniq_id_pair_Ap_Bc = f"{uniq_id_a}_Ap_Bc"
|
461 |
+
uniq_id_pair_Ap_Bp = f"{uniq_id_a}_Ap_Bp"
|
462 |
+
|
463 |
+
# {"audio_filepath": "/disk_a_nvd/datasets/RIRS_NOISES/real_rirs_isotropic_noises/RVB2014_type1_noise_largeroom1_3.wav", "offset": 0, "duration": null, "label": "infer", "text": "-", "num_speakers": null, "rttm_filepath": null, "uem_filepath": null, "ctm_filepath": null}
|
464 |
+
|
465 |
+
uniq_id_a_perturbed = Path(perturbed_audio_A_16k_path).stem
|
466 |
+
uniq_id_b_perturbed = Path(perturbed_audio_B_16k_path).stem
|
467 |
+
|
468 |
+
rttm_path_A = f"{folder_name}/{sub_folder_name}/{uniq_id_a}.rttm"
|
469 |
+
rttm_path_B = f"{folder_name}/{sub_folder_name}/{uniq_id_b}.rttm"
|
470 |
+
rttm_path_A_perturbed = f"{folder_name}/{sub_folder_name}/{uniq_id_a_perturbed}.rttm"
|
471 |
+
rttm_path_B_perturbed = f"{folder_name}/{sub_folder_name}/{uniq_id_b_perturbed}.rttm"
|
472 |
+
|
473 |
+
make_single_speaker_rttm(uniq_id_a, original_filename_A, rttm_path_A, speaker_A)
|
474 |
+
make_single_speaker_rttm(uniq_id_b, original_filename_B, rttm_path_B, speaker_B)
|
475 |
+
make_single_speaker_rttm(uniq_id_a_perturbed, perturbed_audio_A_16k_path, rttm_path_A_perturbed, speaker_A)
|
476 |
+
make_single_speaker_rttm(uniq_id_b_perturbed, perturbed_audio_B_16k_path, rttm_path_B_perturbed, speaker_B)
|
477 |
+
|
478 |
+
rttm_path_pair_Ac_Bc = f"{folder_name}/{sub_folder_name}/{uniq_id_pair}_Ac_Bc.rttm"
|
479 |
+
rttm_path_pair_Ac_Bp = f"{folder_name}/{sub_folder_name}/{uniq_id_pair}_Ac_Bp.rttm"
|
480 |
+
rttm_path_pair_Ap_Bc = f"{folder_name}/{sub_folder_name}/{uniq_id_pair}_Ap_Bc.rttm"
|
481 |
+
rttm_path_pair_Ap_Bp = f"{folder_name}/{sub_folder_name}/{uniq_id_pair}_Ap_Bp.rttm"
|
482 |
+
|
483 |
+
make_two_speaker_rttm(uniq_id_pair_Ac_Bc, original_filename_A, original_filename_B, rttm_path_pair_Ac_Bc, speaker_A, speaker_B)
|
484 |
+
make_two_speaker_rttm(uniq_id_pair_Ac_Bp, original_filename_A, perturbed_audio_B_16k_path, rttm_path_pair_Ac_Bp, speaker_A, speaker_B)
|
485 |
+
make_two_speaker_rttm(uniq_id_pair_Ap_Bc, perturbed_audio_A_16k_path, original_filename_B, rttm_path_pair_Ap_Bc, speaker_A, speaker_B)
|
486 |
+
make_two_speaker_rttm(uniq_id_pair_Ap_Bp, perturbed_audio_A_16k_path, perturbed_audio_B_16k_path, rttm_path_pair_Ap_Bp, speaker_A, speaker_B)
|
487 |
+
|
488 |
+
# Concatenate wav files for 4 different combinations (uniq_id_pair)
|
489 |
+
Ac_Bc_filename = f"{folder_name}/{sub_folder_name}/{uniq_id_pair}_Ac_Bc.wav"
|
490 |
+
Ac_Bp_filename = f"{folder_name}/{sub_folder_name}/{uniq_id_pair}_Ac_Bp.wav"
|
491 |
+
Ap_Bc_filename = f"{folder_name}/{sub_folder_name}/{uniq_id_pair}_Ap_Bc.wav"
|
492 |
+
Ap_Bp_filename = f"{folder_name}/{sub_folder_name}/{uniq_id_pair}_Ap_Bp.wav"
|
493 |
+
|
494 |
+
|
495 |
+
# Concatenate wav files with fade out/fade in transitions
|
496 |
+
Ac_Bc_audio = concat_with_fo_fi(audio_A_16k, audio_B_16k)
|
497 |
+
Ac_Bp_audio = concat_with_fo_fi(audio_A_16k, perturbed_audio_B_16k)
|
498 |
+
Ap_Bc_audio = concat_with_fo_fi(perturbed_audio_A_16k, audio_B_16k)
|
499 |
+
Ap_Bp_audio = concat_with_fo_fi(perturbed_audio_A_16k, perturbed_audio_B_16k)
|
500 |
+
|
501 |
+
sf.write(Ac_Bc_filename, Ac_Bc_audio, 16000)
|
502 |
+
sf.write(Ac_Bp_filename, Ac_Bp_audio, 16000)
|
503 |
+
sf.write(Ap_Bc_filename, Ap_Bc_audio, 16000)
|
504 |
+
sf.write(Ap_Bp_filename, Ap_Bp_audio, 16000)
|
505 |
+
|
506 |
+
indiv_text_manifest_clean.append(get_manifest_entry(original_filename_A, text=gs_text_A, num_speakers=1, rttm_filepath=rttm_path_A, uem_filepath=None, ctm_filepath=None))
|
507 |
+
indiv_text_manifest_clean.append(get_manifest_entry(original_filename_B, text=gs_text_B, num_speakers=1, rttm_filepath=rttm_path_B, uem_filepath=None, ctm_filepath=None))
|
508 |
+
|
509 |
+
indiv_text_manifest_clean_perturbed.append(get_manifest_entry(original_filename_A, text=gs_text_A, num_speakers=1, rttm_filepath=rttm_path_A, uem_filepath=None, ctm_filepath=None))
|
510 |
+
indiv_text_manifest_clean_perturbed.append(get_manifest_entry(perturbed_audio_B_16k_path, text=gs_text_B, num_speakers=1, rttm_filepath=rttm_path_B_perturbed, uem_filepath=None, ctm_filepath=None))
|
511 |
+
|
512 |
+
indiv_text_manifest_perturbed_clean.append(get_manifest_entry(perturbed_audio_A_16k_path, text=gs_text_A, num_speakers=1, rttm_filepath=rttm_path_A_perturbed, uem_filepath=None, ctm_filepath=None))
|
513 |
+
indiv_text_manifest_perturbed_clean.append(get_manifest_entry(original_filename_B, text=gs_text_B, num_speakers=1, rttm_filepath=rttm_path_B, uem_filepath=None, ctm_filepath=None))
|
514 |
+
|
515 |
+
indiv_text_manifest_perturbed.append(get_manifest_entry(perturbed_audio_A_16k_path, text=gs_text_A, num_speakers=1, rttm_filepath=rttm_path_A_perturbed, uem_filepath=None, ctm_filepath=None))
|
516 |
+
indiv_text_manifest_perturbed.append(get_manifest_entry(perturbed_audio_B_16k_path, text=gs_text_B, num_speakers=1, rttm_filepath=rttm_path_B_perturbed, uem_filepath=None, ctm_filepath=None))
|
517 |
+
|
518 |
+
pair_text_manifest_Ac_Bc.append(get_manifest_entry(Ac_Bc_filename, text=pair_gt_text, num_speakers=num_speakers, rttm_filepath=rttm_path_pair_Ac_Bc, uem_filepath=None, ctm_filepath=None))
|
519 |
+
pair_text_manifest_Ac_Bp.append(get_manifest_entry(Ac_Bp_filename, text=pair_gt_text, num_speakers=num_speakers, rttm_filepath=rttm_path_pair_Ac_Bp, uem_filepath=None, ctm_filepath=None))
|
520 |
+
pair_text_manifest_Ap_Bc.append(get_manifest_entry(Ap_Bc_filename, text=pair_gt_text, num_speakers=num_speakers, rttm_filepath=rttm_path_pair_Ap_Bc, uem_filepath=None, ctm_filepath=None))
|
521 |
+
pair_text_manifest_Ap_Bp.append(get_manifest_entry(Ap_Bp_filename, text=pair_gt_text, num_speakers=num_speakers, rttm_filepath=rttm_path_pair_Ap_Bp, uem_filepath=None, ctm_filepath=None))
|
522 |
+
|
523 |
+
# Delete all the json files and overwrite
|
524 |
+
for file in os.listdir(folder_name):
|
525 |
+
if file.endswith('.json'):
|
526 |
+
os.remove(os.path.join(folder_name, file))
|
527 |
+
|
528 |
+
# Write to json files f'{folder_name}'
|
529 |
+
# Overwrite the json files
|
530 |
+
with open(f'{folder_name}/indiv_text_manifest_clean.json', 'w') as f:
|
531 |
+
for entry in indiv_text_manifest_clean:
|
532 |
+
f.write(json.dumps(entry) + '\n')
|
533 |
+
with open(f'{folder_name}/indiv_text_manifest_perturbed.json', 'w') as f:
|
534 |
+
for entry in indiv_text_manifest_perturbed:
|
535 |
+
f.write(json.dumps(entry) + '\n')
|
536 |
+
with open(f'{folder_name}/indiv_text_manifest_clean_perturbed.json', 'w') as f:
|
537 |
+
for entry in indiv_text_manifest_clean_perturbed:
|
538 |
+
f.write(json.dumps(entry) + '\n')
|
539 |
+
with open(f'{folder_name}/indiv_text_manifest_perturbed_clean.json', 'w') as f:
|
540 |
+
for entry in indiv_text_manifest_perturbed_clean:
|
541 |
+
f.write(json.dumps(entry) + '\n')
|
542 |
+
with open(f'{folder_name}/pair_text_manifest_Ac_Bc.json', 'w') as f:
|
543 |
+
for entry in pair_text_manifest_Ac_Bc:
|
544 |
+
f.write(json.dumps(entry) + '\n')
|
545 |
+
with open(f'{folder_name}/pair_text_manifest_Ac_Bp.json', 'w') as f:
|
546 |
+
for entry in pair_text_manifest_Ac_Bp:
|
547 |
+
f.write(json.dumps(entry) + '\n')
|
548 |
+
with open(f'{folder_name}/pair_text_manifest_Ap_Bc.json', 'w') as f:
|
549 |
+
for entry in pair_text_manifest_Ap_Bc:
|
550 |
+
f.write(json.dumps(entry) + '\n')
|
551 |
+
with open(f'{folder_name}/pair_text_manifest_Ap_Bp.json', 'w') as f:
|
552 |
+
for entry in pair_text_manifest_Ap_Bp:
|
553 |
+
f.write(json.dumps(entry) + '\n')
|
utt_samples/A_text4_af_heart.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4fdee8c13f334034d878f1796d4f4f4263c3517fecd23f6f61e3d558b8d960c1
|
3 |
+
size 142844
|
utt_samples/B_text8_af_aoede.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a6c1906b7b2170c02ba92b3f51e9fa4ea042f8a5387a7adcd3de16514b29982f
|
3 |
+
size 140444
|
utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede.rttm
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
SPEAKER A_text00_af_aoede 0.0 4.025 <NA> <NA> af_aoede <NA> <NA>
|
utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0ad80da5d497fe7e1f23fd20ae6b6992ab83e7d5bf49919919931c4b36895b0a
|
3 |
+
size 128844
|
utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede_B_text11_af_aoede_Ac_Bc.rttm
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
SPEAKER A_text00_af_aoede_Ac_Bc 1 0.0 4.025 <NA> <NA> af_aoede <NA> <NA>
|
2 |
+
SPEAKER A_text00_af_aoede_Ac_Bc 1 4.025 2.850 <NA> <NA> af_aoede <NA> <NA>
|
utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede_B_text11_af_aoede_Ac_Bc.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:11bd84a414ab8820d4e8137c63a85950732751a8f96e63da54f6e726891b433c
|
3 |
+
size 207244
|
utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede_B_text11_af_aoede_Ac_Bp.rttm
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
SPEAKER A_text00_af_aoede_Ac_Bp 1 0.0 4.025 <NA> <NA> af_aoede <NA> <NA>
|
2 |
+
SPEAKER A_text00_af_aoede_Ac_Bp 1 4.025 3.350 <NA> <NA> af_aoede <NA> <NA>
|
utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede_B_text11_af_aoede_Ac_Bp.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b0c8d33a67973506fedbda0c76dc435a94f9884a6794995f8f0a77ae9056e8c5
|
3 |
+
size 223242
|
utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede_B_text11_af_aoede_Ap_Bc.rttm
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
SPEAKER A_text00_af_aoede_Ap_Bc 1 0.0 4.525 <NA> <NA> af_aoede <NA> <NA>
|
2 |
+
SPEAKER A_text00_af_aoede_Ap_Bc 1 4.525 2.850 <NA> <NA> af_aoede <NA> <NA>
|
utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede_B_text11_af_aoede_Ap_Bc.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8d31502543e0e6b911d3a05d002283d23584a3ba1431240fefcf441f86ca0fbc
|
3 |
+
size 223242
|
utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede_B_text11_af_aoede_Ap_Bp.rttm
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
SPEAKER A_text00_af_aoede_Ap_Bp 1 0.0 4.525 <NA> <NA> af_aoede <NA> <NA>
|
2 |
+
SPEAKER A_text00_af_aoede_Ap_Bp 1 4.525 3.350 <NA> <NA> af_aoede <NA> <NA>
|
utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede_B_text11_af_aoede_Ap_Bp.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:10cef8db9c6be2c9e5da13cce7f41bf1a8b67c50e70d576ad3a501e622ef1d08
|
3 |
+
size 239240
|
utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede_R_Room088-00049_N_simroom3_9.rttm
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
SPEAKER A_text00_af_aoede_R_Room088-00049_N_simroom3_9 0.0 4.525 <NA> <NA> af_aoede <NA> <NA>
|
utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/A_text00_af_aoede_R_Room088-00049_N_simroom3_9.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:65f6dc8d37e1a61ecbd1ccadc6166936a3c02a80984d871a27f5b14e216fbe47
|
3 |
+
size 144842
|
utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/B_text11_af_aoede.rttm
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
SPEAKER B_text11_af_aoede 0.0 2.850 <NA> <NA> af_aoede <NA> <NA>
|
utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/B_text11_af_aoede.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cc7508aef69b267fa02cb84676f8e4fb84e25d5357295d0ec3fac77aceeeeca6
|
3 |
+
size 91244
|
utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/B_text11_af_aoede_R_Room088-00049_N_simroom3_9.rttm
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
SPEAKER B_text11_af_aoede_R_Room088-00049_N_simroom3_9 0.0 3.350 <NA> <NA> af_aoede <NA> <NA>
|
utt_samples_matched/A_text00_af_aoede_B_text11_af_aoede/B_text11_af_aoede_R_Room088-00049_N_simroom3_9.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3320fc36dd9d2fac393a96956f439f1a833dc5344970e1deb3ee7e30de15cd2b
|
3 |
+
size 107242
|
utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella.rttm
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
SPEAKER A_text00_af_bella 0.0 4.325 <NA> <NA> af_bella <NA> <NA>
|
utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:edf072224d2811d8efb943e7e61f62991952a8e42ba5160a0c2b05a3318f6820
|
3 |
+
size 138444
|
utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella_B_text11_af_bella_Ac_Bc.rttm
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
SPEAKER A_text00_af_bella_Ac_Bc 1 0.0 4.325 <NA> <NA> af_bella <NA> <NA>
|
2 |
+
SPEAKER A_text00_af_bella_Ac_Bc 1 4.325 3.000 <NA> <NA> af_bella <NA> <NA>
|
utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella_B_text11_af_bella_Ac_Bc.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a0108f9762e1fe470fece90bbf792c583cba191468845606e08be7ddd2cdfd56
|
3 |
+
size 221644
|
utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella_B_text11_af_bella_Ac_Bp.rttm
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
SPEAKER A_text00_af_bella_Ac_Bp 1 0.0 4.325 <NA> <NA> af_bella <NA> <NA>
|
2 |
+
SPEAKER A_text00_af_bella_Ac_Bp 1 4.325 3.500 <NA> <NA> af_bella <NA> <NA>
|
utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella_B_text11_af_bella_Ac_Bp.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:79106217d1e8b240427cc310a977a3c76eee08110b77c5cbff0549c2b96bbc46
|
3 |
+
size 237642
|
utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella_B_text11_af_bella_Ap_Bc.rttm
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
SPEAKER A_text00_af_bella_Ap_Bc 1 0.0 4.825 <NA> <NA> af_bella <NA> <NA>
|
2 |
+
SPEAKER A_text00_af_bella_Ap_Bc 1 4.825 3.000 <NA> <NA> af_bella <NA> <NA>
|
utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella_B_text11_af_bella_Ap_Bc.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:757923e4bf0747bf8140f5d31b7ab805b0b94e91d7f857f0206f6a1e947963b1
|
3 |
+
size 237642
|
utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella_B_text11_af_bella_Ap_Bp.rttm
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
SPEAKER A_text00_af_bella_Ap_Bp 1 0.0 4.825 <NA> <NA> af_bella <NA> <NA>
|
2 |
+
SPEAKER A_text00_af_bella_Ap_Bp 1 4.825 3.500 <NA> <NA> af_bella <NA> <NA>
|
utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella_B_text11_af_bella_Ap_Bp.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:24547a0bbcabfeef0e42c4a73ef0d0a9f8f42d49b31ac4a193439bab6515034a
|
3 |
+
size 253640
|
utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella_R_Room073-00024_N_smallroom2_7.rttm
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
SPEAKER A_text00_af_bella_R_Room073-00024_N_smallroom2_7 0.0 4.825 <NA> <NA> af_bella <NA> <NA>
|
utt_samples_matched/A_text00_af_bella_B_text11_af_bella/A_text00_af_bella_R_Room073-00024_N_smallroom2_7.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:11825a9fcc9491e2e342695e812312fcf52a3b30cf9525630505450796c6614a
|
3 |
+
size 154442
|
utt_samples_matched/A_text00_af_bella_B_text11_af_bella/B_text11_af_bella.rttm
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
SPEAKER B_text11_af_bella 0.0 3.000 <NA> <NA> af_bella <NA> <NA>
|
utt_samples_matched/A_text00_af_bella_B_text11_af_bella/B_text11_af_bella.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:161c8269f5cd833f39cfc153b2e4ddba39cd85156d0f4dea7a4c67325d129192
|
3 |
+
size 96044
|
utt_samples_matched/A_text00_af_bella_B_text11_af_bella/B_text11_af_bella_R_Room073-00024_N_smallroom2_7.rttm
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
SPEAKER B_text11_af_bella_R_Room073-00024_N_smallroom2_7 0.0 3.500 <NA> <NA> af_bella <NA> <NA>
|
utt_samples_matched/A_text00_af_bella_B_text11_af_bella/B_text11_af_bella_R_Room073-00024_N_smallroom2_7.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bff76f4551a19bcd39ec2210ba59581026067ae5e44f27a2e9920e69e0159296
|
3 |
+
size 112042
|
utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart.rttm
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
SPEAKER A_text00_af_heart 0.0 4.050 <NA> <NA> af_heart <NA> <NA>
|
utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5edccbf7dbc2ed0cca9d21f13925260ea8edf078e7706d283d41598edde422f7
|
3 |
+
size 129644
|
utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart_B_text11_af_heart_Ac_Bc.rttm
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
SPEAKER A_text00_af_heart_Ac_Bc 1 0.0 4.050 <NA> <NA> af_heart <NA> <NA>
|
2 |
+
SPEAKER A_text00_af_heart_Ac_Bc 1 4.050 2.825 <NA> <NA> af_heart <NA> <NA>
|
utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart_B_text11_af_heart_Ac_Bc.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7a563e8563ab72850e5b7e3f719e6e56b8dd90fffa89412d2f5d776f670c5f65
|
3 |
+
size 207244
|
utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart_B_text11_af_heart_Ac_Bp.rttm
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
SPEAKER A_text00_af_heart_Ac_Bp 1 0.0 4.050 <NA> <NA> af_heart <NA> <NA>
|
2 |
+
SPEAKER A_text00_af_heart_Ac_Bp 1 4.050 3.325 <NA> <NA> af_heart <NA> <NA>
|
utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart_B_text11_af_heart_Ac_Bp.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:903a4fe6479efbc5dccc26df31cd8aa1d34d88fa5e2dc0ebcbd14d627c0e48c1
|
3 |
+
size 223242
|
utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart_B_text11_af_heart_Ap_Bc.rttm
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
SPEAKER A_text00_af_heart_Ap_Bc 1 0.0 4.550 <NA> <NA> af_heart <NA> <NA>
|
2 |
+
SPEAKER A_text00_af_heart_Ap_Bc 1 4.550 2.825 <NA> <NA> af_heart <NA> <NA>
|
utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart_B_text11_af_heart_Ap_Bc.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3f08f56e9f295dd0b544df2ff06b099fcee4c78053c3712442ebfee5854af2d4
|
3 |
+
size 223242
|
utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart_B_text11_af_heart_Ap_Bp.rttm
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
SPEAKER A_text00_af_heart_Ap_Bp 1 0.0 4.550 <NA> <NA> af_heart <NA> <NA>
|
2 |
+
SPEAKER A_text00_af_heart_Ap_Bp 1 4.550 3.325 <NA> <NA> af_heart <NA> <NA>
|
utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart_B_text11_af_heart_Ap_Bp.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:26f22c1c6f9d0a4d089d13e12953dc0beaa6e6f8ea878780333284b1b2e325ac
|
3 |
+
size 239240
|
utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart_R_Room037-00049_N_largeroom1_3.rttm
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
SPEAKER A_text00_af_heart_R_Room037-00049_N_largeroom1_3 0.0 4.550 <NA> <NA> af_heart <NA> <NA>
|
utt_samples_matched/A_text00_af_heart_B_text11_af_heart/A_text00_af_heart_R_Room037-00049_N_largeroom1_3.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b35e6a18aa4888541a1a983f16fbd0cbedd53349476f553d45b7d30112c67217
|
3 |
+
size 145642
|
utt_samples_matched/A_text00_af_heart_B_text11_af_heart/B_text11_af_heart.rttm
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
SPEAKER B_text11_af_heart 0.0 2.825 <NA> <NA> af_heart <NA> <NA>
|
utt_samples_matched/A_text00_af_heart_B_text11_af_heart/B_text11_af_heart.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:68c7675b4af94a0bb3980909d4dc1a716599f28d1731facd9f84ea4a38582108
|
3 |
+
size 90444
|
utt_samples_matched/A_text00_af_heart_B_text11_af_heart/B_text11_af_heart_R_Room037-00049_N_largeroom1_3.rttm
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
SPEAKER B_text11_af_heart_R_Room037-00049_N_largeroom1_3 0.0 3.325 <NA> <NA> af_heart <NA> <NA>
|