bomolopuu commited on
Commit
5d13184
·
1 Parent(s): d3bad75

remove loop

Browse files
Files changed (3) hide show
  1. asr.py +16 -15
  2. audio_plus_hash_uniq_07102024.csv +0 -0
  3. csv_processor.py +4 -3
asr.py CHANGED
@@ -46,21 +46,22 @@ def safe_process_file(file_obj):
46
 
47
  def transcribe_multiple_files(audio_files, lang, transcription):
48
  transcriptions = []
49
- for audio_file in audio_files:
50
- try:
51
- audio_samples, sr, safe_name = safe_process_file(audio_file)
52
- logger.debug(f"Transcribing file: {safe_name}")
53
- logger.debug(f"Language selected: {lang}")
54
- logger.debug(f"User-provided transcription: {transcription}")
55
-
56
- result = transcribe_file(model, audio_samples, lang, transcription)
57
- logger.debug(f"Transcription result: {result}")
58
-
59
- transcriptions.append(f"File: {safe_name}\nTranscription: {result}\n")
60
- except Exception as e:
61
- logger.error(f"Error in transcription process: {str(e)}")
62
- transcriptions.append(f"Error processing file: {str(e)}\n")
63
- return "\n".join(transcriptions)
 
64
 
65
  @spaces.GPU
66
  def transcribe_file(model, audio_samples, lang, user_transcription):
 
46
 
47
  def transcribe_multiple_files(audio_files, lang, transcription):
48
  transcriptions = []
49
+ # for audio_file in audio_files:
50
+ try:
51
+ audio_samples, sr, safe_name = safe_process_file(audio_files)
52
+ logger.debug(f"Transcribing file: {safe_name}")
53
+ logger.debug(f"Language selected: {lang}")
54
+ logger.debug(f"User-provided transcription: {transcription}")
55
+
56
+ result = transcribe_file(model, audio_samples, lang, transcription)
57
+ logger.debug(f"Transcription result: {result}")
58
+
59
+
60
+ transcriptions.append(f"File: {safe_name}\nTranscription: {result}\n")
61
+ except Exception as e:
62
+ logger.error(f"Error in transcription process: {str(e)}")
63
+ transcriptions.append(f"Error processing file: {str(e)}\n")
64
+ # return "\n".join(transcriptions)
65
 
66
  @spaces.GPU
67
  def transcribe_file(model, audio_samples, lang, user_transcription):
audio_plus_hash_uniq_07102024.csv CHANGED
The diff for this file is too large to render. See raw diff
 
csv_processor.py CHANGED
@@ -14,7 +14,7 @@ def hash_md5(filepath):
14
 
15
  import csv
16
 
17
- def update_csv(file_path, search_hash, new_path, new_transcription):
18
  # Use read/write mode to modify the relevant line or append if not found
19
  with open(file_path, mode='r+', newline='', encoding='utf-8') as file:
20
  reader = csv.DictReader(file)
@@ -24,8 +24,8 @@ def update_csv(file_path, search_hash, new_path, new_transcription):
24
 
25
  # Locate the row with the matching hash
26
  for i, row in enumerate(rows):
27
- if row['hash'] == search_hash:
28
- rows[i]['filepath'] = new_path
29
  rows[i]['transcription'] = new_transcription
30
  found = True
31
  break
@@ -42,6 +42,7 @@ def update_csv(file_path, search_hash, new_path, new_transcription):
42
  writer = csv.DictWriter(append_file, fieldnames=fieldnames)
43
  writer.writerow({
44
  'hash': search_hash,
 
45
  'filepath': new_path,
46
  'transcription': new_transcription
47
  })
 
14
 
15
  import csv
16
 
17
+ def update_csv(file_path, search_hash, hash_16000, new_path, new_transcription):
18
  # Use read/write mode to modify the relevant line or append if not found
19
  with open(file_path, mode='r+', newline='', encoding='utf-8') as file:
20
  reader = csv.DictReader(file)
 
24
 
25
  # Locate the row with the matching hash
26
  for i, row in enumerate(rows):
27
+ if row['hash'] == search_hash or row['hash_16000'] == search_hash:
28
+ rows[i]['hash_16000'] = hash_16000
29
  rows[i]['transcription'] = new_transcription
30
  found = True
31
  break
 
42
  writer = csv.DictWriter(append_file, fieldnames=fieldnames)
43
  writer.writerow({
44
  'hash': search_hash,
45
+ 'hash_16000': hash_16000,
46
  'filepath': new_path,
47
  'transcription': new_transcription
48
  })