aoxo commited on
Commit
345d925
1 Parent(s): 75f528c

Upload 2 files

Browse files
Files changed (2) hide show
  1. cleaning.ipynb +490 -0
  2. map.json +0 -0
cleaning.ipynb ADDED
@@ -0,0 +1,490 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "name": "stdout",
10
+ "output_type": "stream",
11
+ "text": [
12
+ "Transcriptions have been extracted and saved successfully.\n"
13
+ ]
14
+ }
15
+ ],
16
+ "source": [
17
+ "import re\n",
18
+ "import os\n",
19
+ "\n",
20
+ "# Path to the transcription file\n",
21
+ "transcription_file = r\"ASR Malayalam\\✅\\mono_male\\transcriptions.txt\"\n",
22
+ "\n",
23
+ "# Create a directory to store the output files (optional)\n",
24
+ "output_dir = r\"ASR Malayalam\\✅\\mono_male\\transcriptions\"\n",
25
+ "os.makedirs(output_dir, exist_ok=True)\n",
26
+ "\n",
27
+ "# Read the transcription file\n",
28
+ "with open(transcription_file, 'r', encoding='utf-8') as file:\n",
29
+ " lines = file.readlines()\n",
30
+ "\n",
31
+ "# Process each line in the transcription file\n",
32
+ "for line in lines:\n",
33
+ " # Use regular expression to match the format and extract the transcription\n",
34
+ " match = re.match(r'\\((\\S+) \"(.*?)\"\\)', line.strip())\n",
35
+ " if match:\n",
36
+ " # Extract the filename (ID) and the Malayalam transcription\n",
37
+ " filename = match.group(1)\n",
38
+ " transcription = match.group(2)\n",
39
+ " \n",
40
+ " # Construct the output file path\n",
41
+ " output_file_path = os.path.join(output_dir, f'{filename}.txt')\n",
42
+ " \n",
43
+ " # Write the transcription to the file\n",
44
+ " with open(output_file_path, 'w', encoding='utf-8') as output_file:\n",
45
+ " output_file.write(transcription)\n",
46
+ "\n",
47
+ "print(\"Transcriptions have been extracted and saved successfully.\")\n",
48
+ "\n",
49
+ "# Paths to the directories containing audio and transcription files\n",
50
+ "audio_dir = r\"ASR Malayalam\\✅\\mono_male\\wav\" # Directory containing .wav files\n",
51
+ "transcription_dir = r\"ASR Malayalam\\✅\\mono_male\\transcriptions\" # Directory containing .txt files\n",
52
+ "\n",
53
+ "# Get a list of all .wav files and .txt files in the respective directories\n",
54
+ "audio_files = {f.replace('.wav', '') for f in os.listdir(audio_dir) if f.endswith('.wav')}\n",
55
+ "transcription_files = {f.replace('.txt', '') for f in os.listdir(transcription_dir) if f.endswith('.txt')}\n",
56
+ "\n",
57
+ "# Find the extra files in each directory that don't have a corresponding match\n",
58
+ "extra_audio_files = audio_files - transcription_files\n",
59
+ "extra_transcription_files = transcription_files - audio_files\n",
60
+ "\n",
61
+ "# Delete extra audio files (those without matching transcription)\n",
62
+ "for file in extra_audio_files:\n",
63
+ " audio_file_path = os.path.join(audio_dir, f\"{file}.wav\")\n",
64
+ " if os.path.exists(audio_file_path):\n",
65
+ " os.remove(audio_file_path)\n",
66
+ " print(f\"Deleted audio file: {audio_file_path}\")\n",
67
+ "\n",
68
+ "# Delete extra transcription files (those without matching audio)\n",
69
+ "for file in extra_transcription_files:\n",
70
+ " transcription_file_path = os.path.join(transcription_dir, f\"{file}.txt\")\n",
71
+ " if os.path.exists(transcription_file_path):\n",
72
+ " os.remove(transcription_file_path)\n",
73
+ " print(f\"Deleted transcription file: {transcription_file_path}\")\n",
74
+ "\n",
75
+ "print(\"Matching files checked and extra files deleted.\")"
76
+ ]
77
+ },
78
+ {
79
+ "cell_type": "code",
80
+ "execution_count": null,
81
+ "metadata": {},
82
+ "outputs": [],
83
+ "source": [
84
+ "import os\n",
85
+ "import re\n",
86
+ "\n",
87
+ "# Paths to the directories containing audio and transcription files\n",
88
+ "audio_dir = r\"💗\\wav\" # Directory containing .wav files\n",
89
+ "transcription_file = r\"💗\\transcriptions.txt\" # Path to the transcription file\n",
90
+ "\n",
91
+ "# Create a directory to store the output files (optional)\n",
92
+ "output_dir = r\"💗\\transcriptions\"\n",
93
+ "os.makedirs(output_dir, exist_ok=True)\n",
94
+ "\n",
95
+ "# Read the transcription file\n",
96
+ "with open(transcription_file, 'r', encoding='utf-8') as file:\n",
97
+ " lines = file.readlines()\n",
98
+ "\n",
99
+ "# Create sets to track the audio files and transcriptions\n",
100
+ "audio_files = {f.replace('.wav', '') for f in os.listdir(audio_dir) if f.endswith('.wav')}\n",
101
+ "transcription_files = set()\n",
102
+ "\n",
103
+ "# Regular expression to extract audio file name and Malayalam text\n",
104
+ "# This pattern matches the audio file name after \"audio/\" and captures the Malayalam transcription at the end\n",
105
+ "transcription_pattern = re.compile(r'\\t(audio/([\\w\\-]+\\.wav))\\t[\\w\\-]+\\t\\d+\\t(.*?)(\\.)')\n",
106
+ "\n",
107
+ "# Process each line in the transcription file\n",
108
+ "for line in lines:\n",
109
+ " # Strip leading/trailing whitespace and search for the pattern\n",
110
+ " match = transcription_pattern.search(line.strip())\n",
111
+ " \n",
112
+ " if match:\n",
113
+ " # Extract the audio file name (without 'audio/' prefix) and the transcription text\n",
114
+ " audio_filename = match.group(2)\n",
115
+ " transcription = match.group(3).strip() # Malayalam transcription\n",
116
+ " \n",
117
+ " # Logging to check if the regex is matching correctly\n",
118
+ " print(f\"Found transcription: Audio File = {audio_filename}, Text = {transcription}\")\n",
119
+ " \n",
120
+ " # Construct the output transcription file path\n",
121
+ " transcription_filename = f'{audio_filename.replace(\".wav\", \"\")}.txt'\n",
122
+ " transcription_file_path = os.path.join(output_dir, transcription_filename)\n",
123
+ " \n",
124
+ " # Write the transcription to the file\n",
125
+ " try:\n",
126
+ " with open(transcription_file_path, 'w', encoding='utf-8') as output_file:\n",
127
+ " output_file.write(transcription)\n",
128
+ " print(f\"Created transcription file: {transcription_file_path}\")\n",
129
+ " except Exception as e:\n",
130
+ " print(f\"Error writing file {transcription_file_path}: {e}\")\n",
131
+ " \n",
132
+ " # Add the transcription identifier to the set\n",
133
+ " transcription_files.add(audio_filename.replace('.wav', ''))\n",
134
+ " else:\n",
135
+ " # If the regex doesn't match, print the problematic line\n",
136
+ " print(f\"Failed to match line: {line.strip()}\")\n",
137
+ "\n",
138
+ "# Find unmatched audio files (those without a corresponding transcription)\n",
139
+ "extra_audio_files = audio_files - transcription_files\n",
140
+ "extra_transcription_files = transcription_files - audio_files\n",
141
+ "\n",
142
+ "# Delete extra audio files (those without matching transcription)\n",
143
+ "for file in extra_audio_files:\n",
144
+ " audio_file_path = os.path.join(audio_dir, f\"{file}.wav\")\n",
145
+ " if os.path.exists(audio_file_path):\n",
146
+ " os.remove(audio_file_path)\n",
147
+ " print(f\"Deleted audio file: {audio_file_path}\")\n",
148
+ "\n",
149
+ "# Delete extra transcription files (those without matching audio)\n",
150
+ "for file in extra_transcription_files:\n",
151
+ " transcription_file_path = os.path.join(output_dir, f\"{file}.txt\")\n",
152
+ " if os.path.exists(transcription_file_path):\n",
153
+ " os.remove(transcription_file_path)\n",
154
+ " print(f\"Deleted transcription file: {transcription_file_path}\")\n",
155
+ "\n",
156
+ "print(\"Matching files checked and extra files deleted.\")"
157
+ ]
158
+ },
159
+ {
160
+ "cell_type": "code",
161
+ "execution_count": null,
162
+ "metadata": {},
163
+ "outputs": [
164
+ {
165
+ "name": "stdout",
166
+ "output_type": "stream",
167
+ "text": [
168
+ "Matching files checked and extra files deleted.\n"
169
+ ]
170
+ }
171
+ ],
172
+ "source": [
173
+ "import os\n",
174
+ "\n",
175
+ "# Paths to the directories containing audio and transcription files\n",
176
+ "audio_dir = \"🗿\\wav\" # Directory containing .wav files\n",
177
+ "transcription_file = r\"🗿\\transcriptions.txt\" # Path to the transcription file\n",
178
+ "\n",
179
+ "# Create a directory to store the output files (optional)\n",
180
+ "output_dir = r\"🗿\\transcriptions\"\n",
181
+ "os.makedirs(output_dir, exist_ok=True)\n",
182
+ "\n",
183
+ "# Read the transcription file\n",
184
+ "with open(transcription_file, 'r', encoding='utf-8') as file:\n",
185
+ " lines = file.readlines()\n",
186
+ "\n",
187
+ "# Create sets to track the audio files and transcriptions\n",
188
+ "audio_files = {f.replace('.wav', '') for f in os.listdir(audio_dir) if f.endswith('.wav')}\n",
189
+ "transcription_files = set()\n",
190
+ "\n",
191
+ "# Process each line in the transcription file\n",
192
+ "for line in lines:\n",
193
+ " columns = line.strip().split('\\t')\n",
194
+ " if len(columns) > 1:\n",
195
+ " # Extract the transcription identifier and the Malayalam transcription\n",
196
+ " transcription_id = columns[0]\n",
197
+ " transcription = columns[1]\n",
198
+ "\n",
199
+ " # Construct the output transcription file path\n",
200
+ " transcription_filename = f'{transcription_id}.txt'\n",
201
+ " transcription_file_path = os.path.join(output_dir, transcription_filename)\n",
202
+ " \n",
203
+ " # Write the transcription to the file\n",
204
+ " with open(transcription_file_path, 'w', encoding='utf-8') as output_file:\n",
205
+ " output_file.write(transcription)\n",
206
+ "\n",
207
+ " # Add the transcription identifier to the set\n",
208
+ " transcription_files.add(transcription_id)\n",
209
+ "\n",
210
+ "# Find unmatched audio files (those without a corresponding transcription)\n",
211
+ "extra_audio_files = audio_files - transcription_files\n",
212
+ "extra_transcription_files = transcription_files - audio_files\n",
213
+ "\n",
214
+ "# Delete extra audio files (those without matching transcription)\n",
215
+ "for file in extra_audio_files:\n",
216
+ " audio_file_path = os.path.join(audio_dir, f\"{file}.wav\")\n",
217
+ " if os.path.exists(audio_file_path):\n",
218
+ " os.remove(audio_file_path)\n",
219
+ " print(f\"Deleted audio file: {audio_file_path}\")\n",
220
+ "\n",
221
+ "# Delete extra transcription files (those without matching audio)\n",
222
+ "for file in extra_transcription_files:\n",
223
+ " transcription_file_path = os.path.join(output_dir, f\"{file}.txt\")\n",
224
+ " if os.path.exists(transcription_file_path):\n",
225
+ " os.remove(transcription_file_path)\n",
226
+ " print(f\"Deleted transcription file: {transcription_file_path}\")\n",
227
+ "\n",
228
+ "print(\"Matching files checked and extra files deleted.\")"
229
+ ]
230
+ },
231
+ {
232
+ "cell_type": "code",
233
+ "execution_count": null,
234
+ "metadata": {},
235
+ "outputs": [
236
+ {
237
+ "name": "stdout",
238
+ "output_type": "stream",
239
+ "text": [
240
+ "Matching files checked and extra files deleted.\n"
241
+ ]
242
+ }
243
+ ],
244
+ "source": [
245
+ "import os\n",
246
+ "\n",
247
+ "# Paths to the directories containing audio and transcription files\n",
248
+ "audio_dir = r\"😭\\Vidhya\\wavs\" # Directory containing .wav files\n",
249
+ "transcription_file = r\"😭\\Vidhya\\transcriptions.txt\" # Path to the transcription file\n",
250
+ "\n",
251
+ "# Create a directory to store the output files (optional)\n",
252
+ "output_dir = r\"😭\\Vidhya\\transcriptions\"\n",
253
+ "os.makedirs(output_dir, exist_ok=True)\n",
254
+ "\n",
255
+ "# Read the transcription file\n",
256
+ "with open(transcription_file, 'r', encoding='utf-8') as file:\n",
257
+ " lines = file.readlines()\n",
258
+ "\n",
259
+ "# Create sets to track the audio files and transcriptions\n",
260
+ "audio_files = {f.replace('.wav', '') for f in os.listdir(audio_dir) if f.endswith('.wav')}\n",
261
+ "transcription_files = set()\n",
262
+ "\n",
263
+ "# Process each line in the transcription file\n",
264
+ "for line in lines:\n",
265
+ " # Split the line at the '|' symbol to separate the identifier and the transcription\n",
266
+ " columns = line.strip().split('|')\n",
267
+ " if len(columns) == 2:\n",
268
+ " transcription_id = columns[0].strip()\n",
269
+ " transcription = columns[1].strip()\n",
270
+ "\n",
271
+ " # Construct the output transcription file path\n",
272
+ " transcription_filename = f'{transcription_id}.txt'\n",
273
+ " transcription_file_path = os.path.join(output_dir, transcription_filename)\n",
274
+ " \n",
275
+ " # Write the transcription to the file\n",
276
+ " with open(transcription_file_path, 'w', encoding='utf-8') as output_file:\n",
277
+ " output_file.write(transcription)\n",
278
+ "\n",
279
+ " # Add the transcription identifier to the set\n",
280
+ " transcription_files.add(transcription_id)\n",
281
+ "\n",
282
+ "# Find unmatched audio files (those without a corresponding transcription)\n",
283
+ "extra_audio_files = audio_files - transcription_files\n",
284
+ "extra_transcription_files = transcription_files - audio_files\n",
285
+ "\n",
286
+ "# Delete extra audio files (those without matching transcription)\n",
287
+ "for file in extra_audio_files:\n",
288
+ " audio_file_path = os.path.join(audio_dir, f\"{file}.wav\")\n",
289
+ " if os.path.exists(audio_file_path):\n",
290
+ " os.remove(audio_file_path)\n",
291
+ " print(f\"Deleted audio file: {audio_file_path}\")\n",
292
+ "\n",
293
+ "# Delete extra transcription files (those without matching audio)\n",
294
+ "for file in extra_transcription_files:\n",
295
+ " transcription_file_path = os.path.join(output_dir, f\"{file}.txt\")\n",
296
+ " if os.path.exists(transcription_file_path):\n",
297
+ " os.remove(transcription_file_path)\n",
298
+ " print(f\"Deleted transcription file: {transcription_file_path}\")\n",
299
+ "\n",
300
+ "print(\"Matching files checked and extra files deleted.\")"
301
+ ]
302
+ },
303
+ {
304
+ "cell_type": "code",
305
+ "execution_count": null,
306
+ "metadata": {},
307
+ "outputs": [],
308
+ "source": [
309
+ "import os\n",
310
+ "import re\n",
311
+ "\n",
312
+ "# Paths to the directories containing audio and transcription files\n",
313
+ "audio_dir = r\"🤑\\wav\" # Directory containing .wav files\n",
314
+ "transcription_file = r\"🤑\\transcriptions.txt\" # Path to the transcription file\n",
315
+ "\n",
316
+ "# Create a directory to store the output files (optional)\n",
317
+ "output_dir = r\"🤑\\transcriptions\"\n",
318
+ "os.makedirs(output_dir, exist_ok=True)\n",
319
+ "\n",
320
+ "# Read the transcription file\n",
321
+ "with open(transcription_file, 'r', encoding='utf-8') as file:\n",
322
+ " lines = file.readlines()\n",
323
+ "\n",
324
+ "# Create sets to track the audio files and transcriptions\n",
325
+ "audio_files = {f.replace('.wav', '') for f in os.listdir(audio_dir) if f.endswith('.wav')}\n",
326
+ "transcription_files = set()\n",
327
+ "\n",
328
+ "# Regular expression to extract transcription ID and Malayalam text\n",
329
+ "# The pattern matches 'mal_' followed by digits and captures everything after that as the transcription text\n",
330
+ "transcription_pattern = re.compile(r'(mal_\\d+)\\s+(.+)')\n",
331
+ "\n",
332
+ "# Process each line in the transcription file\n",
333
+ "for line in lines:\n",
334
+ " # Strip leading/trailing whitespace and search for the pattern\n",
335
+ " match = transcription_pattern.search(line.strip())\n",
336
+ " \n",
337
+ " if match:\n",
338
+ " transcription_id = match.group(1)\n",
339
+ " transcription = match.group(2).strip() # Capture the Malayalam text and remove surrounding whitespace\n",
340
+ " \n",
341
+ " # Logging to check if the regex is matching correctly\n",
342
+ " print(f\"Found transcription: ID = {transcription_id}, Text = {transcription}\")\n",
343
+ " \n",
344
+ " # Construct the output transcription file path\n",
345
+ " transcription_filename = f'{transcription_id}.txt'\n",
346
+ " transcription_file_path = os.path.join(output_dir, transcription_filename)\n",
347
+ " \n",
348
+ " # Write the transcription to the file\n",
349
+ " try:\n",
350
+ " with open(transcription_file_path, 'w', encoding='utf-8') as output_file:\n",
351
+ " output_file.write(transcription)\n",
352
+ " print(f\"Created transcription file: {transcription_file_path}\")\n",
353
+ " except Exception as e:\n",
354
+ " print(f\"Error writing file {transcription_file_path}: {e}\")\n",
355
+ " \n",
356
+ " # Add the transcription identifier to the set\n",
357
+ " transcription_files.add(transcription_id)\n",
358
+ " else:\n",
359
+ " # If the regex doesn't match, print the problematic line\n",
360
+ " print(f\"Failed to match line: {line.strip()}\")\n",
361
+ "\n",
362
+ "# Find unmatched audio files (those without a corresponding transcription)\n",
363
+ "extra_audio_files = audio_files - transcription_files\n",
364
+ "extra_transcription_files = transcription_files - audio_files\n",
365
+ "\n",
366
+ "# Delete extra audio files (those without matching transcription)\n",
367
+ "for file in extra_audio_files:\n",
368
+ " audio_file_path = os.path.join(audio_dir, f\"{file}.wav\")\n",
369
+ " if os.path.exists(audio_file_path):\n",
370
+ " os.remove(audio_file_path)\n",
371
+ " print(f\"Deleted audio file: {audio_file_path}\")\n",
372
+ "\n",
373
+ "# Delete extra transcription files (those without matching audio)\n",
374
+ "for file in extra_transcription_files:\n",
375
+ " transcription_file_path = os.path.join(output_dir, f\"{file}.txt\")\n",
376
+ " if os.path.exists(transcription_file_path):\n",
377
+ " os.remove(transcription_file_path)\n",
378
+ " print(f\"Deleted transcription file: {transcription_file_path}\")\n",
379
+ "\n",
380
+ "print(\"Matching files checked and extra files deleted.\")"
381
+ ]
382
+ },
383
+ {
384
+ "cell_type": "markdown",
385
+ "metadata": {},
386
+ "source": [
387
+ "### CREATE JSON MAPPING BETWEEN WAV & TRANSCRIPTIONS"
388
+ ]
389
+ },
390
+ {
391
+ "cell_type": "code",
392
+ "execution_count": null,
393
+ "metadata": {},
394
+ "outputs": [
395
+ {
396
+ "name": "stdout",
397
+ "output_type": "stream",
398
+ "text": [
399
+ "Mapping created successfully. Output saved to D:\\ASR Malayalam\\map.json\n"
400
+ ]
401
+ }
402
+ ],
403
+ "source": [
404
+ "import os\n",
405
+ "import json\n",
406
+ "\n",
407
+ "# Directory structure\n",
408
+ "base_dir = r\"./\" # Path to the directory containing the 6 folders\n",
409
+ "output_json_file = r\"map.json\" # Output file for the JSON mapping\n",
410
+ "\n",
411
+ "# Initialize the dictionary to hold the mappings\n",
412
+ "file_mapping = {}\n",
413
+ "\n",
414
+ "# List all the folders in the base directory\n",
415
+ "folders = [folder for folder in os.listdir(base_dir) if os.path.isdir(os.path.join(base_dir, folder))]\n",
416
+ "\n",
417
+ "# Loop over each folder (assumed to be named with 6 unique names)\n",
418
+ "for folder in folders:\n",
419
+ " wav_folder = os.path.join(base_dir, folder, 'wav') # Path to the 'wav' subfolder\n",
420
+ " transcription_folder = os.path.join(base_dir, folder, 'transcription') # Path to the 'transcription' subfolder\n",
421
+ "\n",
422
+ " # List all .wav files in the 'wav' folder\n",
423
+ " wav_files = [f for f in os.listdir(wav_folder) if f.endswith('.wav')]\n",
424
+ " \n",
425
+ " # List all .txt files in the 'transcription' folder\n",
426
+ " transcription_files = [f for f in os.listdir(transcription_folder) if f.endswith('.txt')]\n",
427
+ "\n",
428
+ " # Create mappings for each .wav file to its corresponding .txt transcription file\n",
429
+ " for wav_file in wav_files:\n",
430
+ " # Assuming the transcription filename is the same as the wav filename but with a .txt extension\n",
431
+ " transcription_file = wav_file.replace('.wav', '.txt')\n",
432
+ "\n",
433
+ " # Check if the corresponding transcription file exists\n",
434
+ " if transcription_file in transcription_files:\n",
435
+ " # Add to the mapping\n",
436
+ " file_mapping[os.path.join(wav_folder, wav_file)] = os.path.join(transcription_folder, transcription_file)\n",
437
+ "\n",
438
+ "# Write the JSON output to a file\n",
439
+ "with open(output_json_file, 'w', encoding='utf-8') as json_file:\n",
440
+ " json.dump(file_mapping, json_file, ensure_ascii=False, indent=4)\n",
441
+ "\n",
442
+ "print(f\"Mapping created successfully. Output saved to {output_json_file}\")"
443
+ ]
444
+ },
445
+ {
446
+ "cell_type": "code",
447
+ "execution_count": 2,
448
+ "metadata": {},
449
+ "outputs": [
450
+ {
451
+ "name": "stdout",
452
+ "output_type": "stream",
453
+ "text": [
454
+ "1\n"
455
+ ]
456
+ }
457
+ ],
458
+ "source": [
459
+ "import os\n",
460
+ "\n",
461
+ "# Set the environment variable\n",
462
+ "os.environ[\"HF_HUB_ENABLE_HF_TRANSFER\"] = \"1\"\n",
463
+ "\n",
464
+ "# Check if the environment variable is set\n",
465
+ "print(os.environ.get(\"HF_HUB_ENABLE_HF_TRANSFER\"))"
466
+ ]
467
+ }
468
+ ],
469
+ "metadata": {
470
+ "kernelspec": {
471
+ "display_name": "tf",
472
+ "language": "python",
473
+ "name": "python3"
474
+ },
475
+ "language_info": {
476
+ "codemirror_mode": {
477
+ "name": "ipython",
478
+ "version": 3
479
+ },
480
+ "file_extension": ".py",
481
+ "mimetype": "text/x-python",
482
+ "name": "python",
483
+ "nbconvert_exporter": "python",
484
+ "pygments_lexer": "ipython3",
485
+ "version": "3.10.11"
486
+ }
487
+ },
488
+ "nbformat": 4,
489
+ "nbformat_minor": 2
490
+ }
map.json ADDED
The diff for this file is too large to render. See raw diff