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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Besm ALLAH
|
| 2 |
+
# Code for recording audio dataset, reads a txt file placed nearby. The txt file is assumed to have a single column with normalized text
|
| 3 |
+
|
| 4 |
+
# pip install PyQt5 sounddevice soundfile numpy
|
| 5 |
+
# sudo apt-get install libportaudio2
|
| 6 |
+
|
| 7 |
+
import sys
|
| 8 |
+
import os
|
| 9 |
+
import re
|
| 10 |
+
from PyQt5.QtWidgets import (QApplication, QMainWindow, QVBoxLayout, QWidget,
|
| 11 |
+
QPushButton, QLabel, QHBoxLayout, QLineEdit)
|
| 12 |
+
from PyQt5.QtCore import Qt, QTimer
|
| 13 |
+
import sounddevice as sd
|
| 14 |
+
import soundfile as sf
|
| 15 |
+
import numpy as np
|
| 16 |
+
import glob
|
| 17 |
+
|
| 18 |
+
class VoiceRecorderApp(QMainWindow):
|
| 19 |
+
def __init__(self):
|
| 20 |
+
super().__init__()
|
| 21 |
+
self.setWindowTitle("Voice Recorder")
|
| 22 |
+
self.setGeometry(100, 100, 800, 600) # Increased window size
|
| 23 |
+
|
| 24 |
+
# Recording variables
|
| 25 |
+
self.is_recording = False
|
| 26 |
+
self.recording = None
|
| 27 |
+
self.fs = 44100
|
| 28 |
+
self.current_number = 0
|
| 29 |
+
self.lines = []
|
| 30 |
+
|
| 31 |
+
# Create wav directory if it doesn't exist
|
| 32 |
+
os.makedirs("wav", exist_ok=True)
|
| 33 |
+
|
| 34 |
+
self.init_ui()
|
| 35 |
+
self.load_text_file()
|
| 36 |
+
self.find_next_available_number()
|
| 37 |
+
|
| 38 |
+
def init_ui(self):
|
| 39 |
+
central_widget = QWidget()
|
| 40 |
+
self.setCentralWidget(central_widget)
|
| 41 |
+
layout = QVBoxLayout()
|
| 42 |
+
|
| 43 |
+
# Button row
|
| 44 |
+
button_row = QHBoxLayout()
|
| 45 |
+
|
| 46 |
+
# Record button (now wider)
|
| 47 |
+
self.record_btn = QPushButton("🎤 Start Recording (Space)")
|
| 48 |
+
self.record_btn.setStyleSheet("""
|
| 49 |
+
QPushButton {
|
| 50 |
+
background-color: #4CAF50;
|
| 51 |
+
color: white;
|
| 52 |
+
font-size: 16px;
|
| 53 |
+
padding: 15px 30px;
|
| 54 |
+
min-width: 200px;
|
| 55 |
+
}
|
| 56 |
+
""")
|
| 57 |
+
self.record_btn.clicked.connect(self.toggle_recording)
|
| 58 |
+
button_row.addWidget(self.record_btn)
|
| 59 |
+
|
| 60 |
+
# Recording indicator
|
| 61 |
+
self.recording_indicator = QLabel()
|
| 62 |
+
self.recording_indicator.setFixedSize(40, 40)
|
| 63 |
+
button_row.addWidget(self.recording_indicator)
|
| 64 |
+
|
| 65 |
+
# Stop button
|
| 66 |
+
self.stop_btn = QPushButton("⏹ Stop & Save (Space)")
|
| 67 |
+
self.stop_btn.setStyleSheet("""
|
| 68 |
+
QPushButton {
|
| 69 |
+
background-color: #2196F3;
|
| 70 |
+
color: white;
|
| 71 |
+
font-size: 16px;
|
| 72 |
+
padding: 15px 30px;
|
| 73 |
+
min-width: 200px;
|
| 74 |
+
}
|
| 75 |
+
QPushButton:disabled {
|
| 76 |
+
background-color: #cccccc;
|
| 77 |
+
}
|
| 78 |
+
""")
|
| 79 |
+
self.stop_btn.clicked.connect(self.stop_recording)
|
| 80 |
+
self.stop_btn.setEnabled(False)
|
| 81 |
+
button_row.addWidget(self.stop_btn)
|
| 82 |
+
|
| 83 |
+
# Skip button
|
| 84 |
+
self.skip_btn = QPushButton("⏭ Skip (S)")
|
| 85 |
+
self.skip_btn.setStyleSheet("""
|
| 86 |
+
QPushButton {
|
| 87 |
+
background-color: #FF9800;
|
| 88 |
+
color: white;
|
| 89 |
+
font-size: 16px;
|
| 90 |
+
padding: 15px 30px;
|
| 91 |
+
min-width: 200px;
|
| 92 |
+
}
|
| 93 |
+
QPushButton:disabled {
|
| 94 |
+
background-color: #cccccc;
|
| 95 |
+
}
|
| 96 |
+
""")
|
| 97 |
+
self.skip_btn.clicked.connect(self.skip_recording)
|
| 98 |
+
self.skip_btn.setEnabled(False)
|
| 99 |
+
button_row.addWidget(self.skip_btn)
|
| 100 |
+
|
| 101 |
+
# Cancel button
|
| 102 |
+
self.cancel_btn = QPushButton("✖ Cancel (ESC)")
|
| 103 |
+
self.cancel_btn.setStyleSheet("""
|
| 104 |
+
QPushButton {
|
| 105 |
+
background-color: #f44336;
|
| 106 |
+
color: white;
|
| 107 |
+
font-size: 16px;
|
| 108 |
+
padding: 15px 30px;
|
| 109 |
+
min-width: 200px;
|
| 110 |
+
}
|
| 111 |
+
QPushButton:disabled {
|
| 112 |
+
background-color: #cccccc;
|
| 113 |
+
}
|
| 114 |
+
""")
|
| 115 |
+
self.cancel_btn.clicked.connect(self.cancel_recording)
|
| 116 |
+
self.cancel_btn.setEnabled(False)
|
| 117 |
+
button_row.addWidget(self.cancel_btn)
|
| 118 |
+
|
| 119 |
+
layout.addLayout(button_row)
|
| 120 |
+
|
| 121 |
+
# Status label
|
| 122 |
+
self.status_label = QLabel("Ready to record (Press Space to start)")
|
| 123 |
+
self.status_label.setStyleSheet("font-size: 16px;")
|
| 124 |
+
layout.addWidget(self.status_label)
|
| 125 |
+
|
| 126 |
+
# Current number display (moved below buttons)
|
| 127 |
+
counter_row = QHBoxLayout()
|
| 128 |
+
counter_label = QLabel("Current #:")
|
| 129 |
+
counter_label.setStyleSheet("font-size: 18px;")
|
| 130 |
+
|
| 131 |
+
self.counter_display = QLineEdit("0000")
|
| 132 |
+
self.counter_display.setReadOnly(True)
|
| 133 |
+
self.counter_display.setStyleSheet("""
|
| 134 |
+
QLineEdit {
|
| 135 |
+
font-size: 24px;
|
| 136 |
+
font-weight: bold;
|
| 137 |
+
border: 2px solid #ccc;
|
| 138 |
+
padding: 10px;
|
| 139 |
+
min-width: 100px;
|
| 140 |
+
max-width: 100px;
|
| 141 |
+
}
|
| 142 |
+
""")
|
| 143 |
+
self.counter_display.setAlignment(Qt.AlignCenter)
|
| 144 |
+
|
| 145 |
+
counter_row.addWidget(counter_label)
|
| 146 |
+
counter_row.addWidget(self.counter_display)
|
| 147 |
+
counter_row.addStretch()
|
| 148 |
+
layout.addLayout(counter_row)
|
| 149 |
+
|
| 150 |
+
# Text display with larger font
|
| 151 |
+
self.file_label = QLabel()
|
| 152 |
+
self.file_label.setStyleSheet("""
|
| 153 |
+
QLabel {
|
| 154 |
+
font-size: 36px;
|
| 155 |
+
padding: 20px;
|
| 156 |
+
border: 2px solid #ddd;
|
| 157 |
+
background-color: #f9f9f9;
|
| 158 |
+
min-height: 200px;
|
| 159 |
+
qproperty-alignment: 'AlignTop | AlignRight';
|
| 160 |
+
}
|
| 161 |
+
""")
|
| 162 |
+
self.file_label.setWordWrap(True)
|
| 163 |
+
layout.addWidget(self.file_label)
|
| 164 |
+
|
| 165 |
+
central_widget.setLayout(layout)
|
| 166 |
+
|
| 167 |
+
# Keyboard shortcuts
|
| 168 |
+
self.record_btn.setShortcut("Space")
|
| 169 |
+
self.stop_btn.setShortcut("Space")
|
| 170 |
+
self.skip_btn.setShortcut("S")
|
| 171 |
+
self.cancel_btn.setShortcut("Escape")
|
| 172 |
+
|
| 173 |
+
def process_text_with_directions(self, text):
|
| 174 |
+
"""
|
| 175 |
+
Process text to automatically insert line breaks at script changes.
|
| 176 |
+
Returns formatted text with RTL/LTR markers and the overall direction.
|
| 177 |
+
"""
|
| 178 |
+
if not text:
|
| 179 |
+
return "", Qt.LeftToRight
|
| 180 |
+
|
| 181 |
+
# Split text into segments by script
|
| 182 |
+
segments = []
|
| 183 |
+
current_script = None
|
| 184 |
+
current_segment = []
|
| 185 |
+
|
| 186 |
+
for char in text:
|
| 187 |
+
# Determine script for current character
|
| 188 |
+
if '\u0600' <= char <= '\u06FF' or '\u0750' <= char <= '\u077F':
|
| 189 |
+
char_script = 'rtl'
|
| 190 |
+
elif char.isalpha():
|
| 191 |
+
char_script = 'ltr'
|
| 192 |
+
else:
|
| 193 |
+
char_script = current_script # Non-letters inherit current script
|
| 194 |
+
|
| 195 |
+
# Start new segment if script changes
|
| 196 |
+
if char_script != current_script and current_segment:
|
| 197 |
+
segments.append((''.join(current_segment), current_script))
|
| 198 |
+
current_segment = []
|
| 199 |
+
|
| 200 |
+
current_script = char_script
|
| 201 |
+
current_segment.append(char)
|
| 202 |
+
|
| 203 |
+
# Add the last segment
|
| 204 |
+
if current_segment:
|
| 205 |
+
segments.append((''.join(current_segment), current_script))
|
| 206 |
+
|
| 207 |
+
# Determine overall direction
|
| 208 |
+
overall_direction = Qt.RightToLeft if any(s[1] == 'rtl' for s in segments) else Qt.LeftToRight
|
| 209 |
+
|
| 210 |
+
# Format segments with proper direction markers
|
| 211 |
+
formatted_lines = []
|
| 212 |
+
for segment, script in segments:
|
| 213 |
+
if script == 'rtl':
|
| 214 |
+
formatted_lines.append("\u202B" + segment + "\u202C") # RTL embedding
|
| 215 |
+
else:
|
| 216 |
+
formatted_lines.append("\u202A" + segment + "\u202C") # LTR embedding
|
| 217 |
+
|
| 218 |
+
return '\n'.join(formatted_lines), overall_direction
|
| 219 |
+
|
| 220 |
+
def load_text_file(self):
|
| 221 |
+
"""Load text file and prepare lines"""
|
| 222 |
+
try:
|
| 223 |
+
txt_files = glob.glob('*.txt')
|
| 224 |
+
if not txt_files:
|
| 225 |
+
self.status_label.setText("No .txt file found in directory")
|
| 226 |
+
return
|
| 227 |
+
|
| 228 |
+
with open(txt_files[0], 'r', encoding='utf-8') as f:
|
| 229 |
+
raw_lines = [line.strip() for line in f.readlines() if line.strip()]
|
| 230 |
+
|
| 231 |
+
if not raw_lines:
|
| 232 |
+
self.status_label.setText("Text file is empty")
|
| 233 |
+
self.record_btn.setEnabled(False)
|
| 234 |
+
return
|
| 235 |
+
|
| 236 |
+
# Process each line for proper direction handling
|
| 237 |
+
self.lines = []
|
| 238 |
+
for line in raw_lines:
|
| 239 |
+
processed_line, _ = self.process_text_with_directions(line)
|
| 240 |
+
self.lines.append(processed_line)
|
| 241 |
+
|
| 242 |
+
except Exception as e:
|
| 243 |
+
self.status_label.setText(f"Error reading file: {str(e)}")
|
| 244 |
+
|
| 245 |
+
def find_next_available_number(self):
|
| 246 |
+
"""Find the next available WAV file number, considering gaps"""
|
| 247 |
+
existing_files = glob.glob('wav/*.wav')
|
| 248 |
+
existing_numbers = []
|
| 249 |
+
|
| 250 |
+
for f in existing_files:
|
| 251 |
+
try:
|
| 252 |
+
num = int(os.path.splitext(os.path.basename(f))[0])
|
| 253 |
+
existing_numbers.append(num)
|
| 254 |
+
except ValueError:
|
| 255 |
+
continue
|
| 256 |
+
|
| 257 |
+
if not existing_numbers:
|
| 258 |
+
self.current_number = 1
|
| 259 |
+
else:
|
| 260 |
+
max_num = max(existing_numbers)
|
| 261 |
+
all_numbers = set(range(1, max_num + 1))
|
| 262 |
+
missing = sorted(all_numbers - set(existing_numbers))
|
| 263 |
+
if missing:
|
| 264 |
+
self.current_number = missing[0] # Use first gap
|
| 265 |
+
else:
|
| 266 |
+
self.current_number = max_num + 1 # No gaps, use next number
|
| 267 |
+
|
| 268 |
+
self.update_display()
|
| 269 |
+
|
| 270 |
+
def update_display(self):
|
| 271 |
+
"""Update counter and display processed text"""
|
| 272 |
+
self.counter_display.setText(f"{self.current_number:04d}")
|
| 273 |
+
|
| 274 |
+
line_index = self.current_number - 1
|
| 275 |
+
if line_index < len(self.lines):
|
| 276 |
+
display_text = self.lines[line_index]
|
| 277 |
+
|
| 278 |
+
# Determine overall direction for alignment
|
| 279 |
+
if any('\u202B' in part for part in display_text.split('\n')):
|
| 280 |
+
self.file_label.setLayoutDirection(Qt.RightToLeft)
|
| 281 |
+
self.file_label.setAlignment(Qt.AlignRight | Qt.AlignTop)
|
| 282 |
+
else:
|
| 283 |
+
self.file_label.setLayoutDirection(Qt.LeftToRight)
|
| 284 |
+
self.file_label.setAlignment(Qt.AlignLeft | Qt.AlignTop)
|
| 285 |
+
|
| 286 |
+
self.file_label.setText(display_text)
|
| 287 |
+
else:
|
| 288 |
+
self.file_label.setText("No text available for this number")
|
| 289 |
+
|
| 290 |
+
def toggle_recording(self):
|
| 291 |
+
if self.is_recording:
|
| 292 |
+
self.stop_recording()
|
| 293 |
+
else:
|
| 294 |
+
self.start_recording()
|
| 295 |
+
|
| 296 |
+
def start_recording(self):
|
| 297 |
+
self.is_recording = True
|
| 298 |
+
self.recording = []
|
| 299 |
+
|
| 300 |
+
# Update UI
|
| 301 |
+
self.record_btn.setEnabled(False)
|
| 302 |
+
self.stop_btn.setEnabled(True)
|
| 303 |
+
self.skip_btn.setEnabled(True)
|
| 304 |
+
self.cancel_btn.setEnabled(True)
|
| 305 |
+
self.status_label.setText("Recording... (Space=Stop, S=Skip, ESC=Cancel)")
|
| 306 |
+
self.status_label.setStyleSheet("color: red; font-size: 12px;")
|
| 307 |
+
|
| 308 |
+
# Show recording indicator
|
| 309 |
+
self.recording_indicator.setStyleSheet("background-color: red; border-radius: 15px;")
|
| 310 |
+
self.indicator_animation()
|
| 311 |
+
|
| 312 |
+
# Start recording
|
| 313 |
+
def callback(indata, frames, time, status):
|
| 314 |
+
if self.is_recording:
|
| 315 |
+
self.recording.append(indata.copy())
|
| 316 |
+
|
| 317 |
+
self.stream = sd.InputStream(
|
| 318 |
+
samplerate=self.fs,
|
| 319 |
+
channels=1,
|
| 320 |
+
callback=callback,
|
| 321 |
+
dtype='float32'
|
| 322 |
+
)
|
| 323 |
+
self.stream.start()
|
| 324 |
+
|
| 325 |
+
def indicator_animation(self):
|
| 326 |
+
if self.is_recording:
|
| 327 |
+
current_color = self.recording_indicator.styleSheet()
|
| 328 |
+
new_color = "background-color: darkred; border-radius: 15px;" if "red" in current_color else "background-color: red; border-radius: 15px;"
|
| 329 |
+
self.recording_indicator.setStyleSheet(new_color)
|
| 330 |
+
QTimer.singleShot(500, self.indicator_animation)
|
| 331 |
+
|
| 332 |
+
def stop_recording(self):
|
| 333 |
+
self.is_recording = False
|
| 334 |
+
if hasattr(self, 'stream'):
|
| 335 |
+
self.stream.stop()
|
| 336 |
+
self.stream.close()
|
| 337 |
+
|
| 338 |
+
# Save recording
|
| 339 |
+
if len(self.recording) > 0:
|
| 340 |
+
recording_array = np.concatenate(self.recording, axis=0)
|
| 341 |
+
wav_path = f"wav/{self.current_number:04d}.wav"
|
| 342 |
+
sf.write(wav_path, recording_array, self.fs)
|
| 343 |
+
|
| 344 |
+
# Find next available number
|
| 345 |
+
self.find_next_available_number()
|
| 346 |
+
|
| 347 |
+
# Update UI
|
| 348 |
+
self.reset_ui()
|
| 349 |
+
self.status_label.setText("Recording saved")
|
| 350 |
+
self.status_label.setStyleSheet("color: green; font-size: 12px;")
|
| 351 |
+
self.recording_indicator.setStyleSheet("")
|
| 352 |
+
|
| 353 |
+
def skip_recording(self):
|
| 354 |
+
"""Skip current recording by saving empty WAV file"""
|
| 355 |
+
self.is_recording = False
|
| 356 |
+
if hasattr(self, 'stream'):
|
| 357 |
+
self.stream.stop()
|
| 358 |
+
self.stream.close()
|
| 359 |
+
|
| 360 |
+
# Save empty WAV file
|
| 361 |
+
empty_array = np.zeros(0, dtype='float32')
|
| 362 |
+
wav_path = f"wav/{self.current_number:04d}.wav"
|
| 363 |
+
sf.write(wav_path, empty_array, self.fs)
|
| 364 |
+
|
| 365 |
+
# Find next available number
|
| 366 |
+
self.find_next_available_number()
|
| 367 |
+
|
| 368 |
+
# Update UI
|
| 369 |
+
self.reset_ui()
|
| 370 |
+
self.status_label.setText("Recording skipped (empty file saved)")
|
| 371 |
+
self.status_label.setStyleSheet("color: orange; font-size: 12px;")
|
| 372 |
+
self.recording_indicator.setStyleSheet("")
|
| 373 |
+
|
| 374 |
+
def cancel_recording(self):
|
| 375 |
+
self.is_recording = False
|
| 376 |
+
if hasattr(self, 'stream'):
|
| 377 |
+
self.stream.stop()
|
| 378 |
+
self.stream.close()
|
| 379 |
+
|
| 380 |
+
# Update UI
|
| 381 |
+
self.reset_ui()
|
| 382 |
+
self.status_label.setText("Recording canceled")
|
| 383 |
+
self.status_label.setStyleSheet("color: orange; font-size: 12px;")
|
| 384 |
+
self.recording_indicator.setStyleSheet("")
|
| 385 |
+
|
| 386 |
+
def reset_ui(self):
|
| 387 |
+
self.record_btn.setEnabled(True)
|
| 388 |
+
self.stop_btn.setEnabled(False)
|
| 389 |
+
self.skip_btn.setEnabled(False)
|
| 390 |
+
self.cancel_btn.setEnabled(False)
|
| 391 |
+
|
| 392 |
+
if __name__ == "__main__":
|
| 393 |
+
app = QApplication(sys.argv)
|
| 394 |
+
recorder = VoiceRecorderApp()
|
| 395 |
+
recorder.show()
|
| 396 |
+
sys.exit(app.exec_())
|
DatasetRecorder/dataset_FA-EN-AR.txt-result.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
DatasetRecorder/runDatasetRecorder.bat
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
python ./datasetRecorderGUI.py
|
DatasetRecorder/updateDatasetRecorder.bat
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@echo off
|
| 2 |
+
set "url=https://huggingface.co/datasets/mah92/Phone-FA-EN-AR-Dataset/resolve/main/datasetRecorderGUI.py"
|
| 3 |
+
set "output=./datasetRecorderGUI.py"
|
| 4 |
+
|
| 5 |
+
powershell -Command "Invoke-WebRequest -Uri '%url%' -OutFile '%output%'"
|
| 6 |
+
|
| 7 |
+
set "url2=https://huggingface.co/datasets/mah92/Phone-FA-EN-AR-Dataset/resolve/main/runDatasetRecorder.bat"
|
| 8 |
+
set "output2=./runDatasetRecorder.bat"
|
| 9 |
+
|
| 10 |
+
powershell -Command "Invoke-WebRequest -Uri '%url2%' -OutFile '%output2%'"
|