Maximofn commited on
Commit
fdb83d2
1 Parent(s): 1215bc9

Manage files into transcribe.py

Browse files
Files changed (1) hide show
  1. transcribe.py +19 -5
transcribe.py CHANGED
@@ -1,9 +1,7 @@
1
  import os
2
  import argparse
3
 
4
- def main(args):
5
- audio_file = args.input
6
- language = args.language
7
  output_folder = "transcriptions"
8
 
9
  # Transcribe audio file
@@ -21,7 +19,23 @@ def main(args):
21
 
22
  if __name__ == "__main__":
23
  parser = argparse.ArgumentParser(description='Transcribe audio files')
24
- parser.add_argument('input', help='Input audio file')
25
  parser.add_argument('language', help='Language of the audio file')
 
26
  args = parser.parse_args()
27
- main(args)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
  import argparse
3
 
4
+ def transcribe(audio_file, language):
 
 
5
  output_folder = "transcriptions"
6
 
7
  # Transcribe audio file
 
19
 
20
  if __name__ == "__main__":
21
  parser = argparse.ArgumentParser(description='Transcribe audio files')
22
+ parser.add_argument('input_files', help='Input audio files')
23
  parser.add_argument('language', help='Language of the audio file')
24
+ parser.add_argument('speakers_file', help='File with the number of speakers')
25
  args = parser.parse_args()
26
+
27
+ vocals_folder = "vocals"
28
+ extension = "wav"
29
+
30
+ with open(args.speakers_file, 'r') as f:
31
+ speakers = f.read().splitlines()
32
+ speakers = int(speakers[0])
33
+
34
+ with open(args.input_files, 'r') as f:
35
+ inputs = f.read().splitlines()
36
+ for input in inputs:
37
+ input, _ = input.split('.')
38
+ _, input_name = input.split('/')
39
+ for i in range(speakers):
40
+ file = f'{vocals_folder}/{input_name}_speaker{i:003d}.{extension}'
41
+ transcribe(file, args.language)