AngeT10 commited on
Commit
2b377db
1 Parent(s): 029f491

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -14
app.py CHANGED
@@ -40,20 +40,23 @@ def extract_zip_file(zip_file: str) -> bool:
40
  print(f"Error extracting zip file: {e}")
41
  return False
42
 
43
- def audio_processing:
44
- def convert_to_wav(input_audio_file: str) -> str:
45
- file_extension = os.path.splitext(input_audio_file)[-1].lower()
46
- if file_extension!= ".wav":
47
- audio = AudioSegment.from_file(input_audio_file)
48
- audio.export("temp.wav", format="wav")
49
- os.remove(input_audio_file)
50
- return "temp.wav"
51
- return input_audio_file
52
 
53
- def synthesize_text(text: str, input_audio_file: str, language: str) -> str:
54
- input_audio_file = convert_to_wav(input_audio_file)
55
- tts.tts_to_file(text=text, speaker_wav=input_audio_file, language=language, file_path="./output.wav")
56
- return "./output.wav"
 
 
 
 
57
 
58
  def voice_clone(text: str, input_file: gr.File, language: str, url: gr.Audio) -> str:
59
  if input_file is not None:
@@ -72,7 +75,7 @@ def voice_clone(text: str, input_file: gr.File, language: str, url: gr.Audio) ->
72
  return"Error: Please select a file or enter a URL"
73
  if language not in LANGUAGES:
74
  return "Error: Invalid language selected"
75
- output_file_path = synthesize_text(text, input_audio_file, language)
76
  return output_file_path
77
 
78
  iface = gr.Interface(
 
40
  print(f"Error extracting zip file: {e}")
41
  return False
42
 
43
+ def convert_to_wav(input_audio_file: str) -> str:
44
+ file_extension = os.path.splitext(input_audio_file)[-1].lower()
45
+ if file_extension!= ".wav":
46
+ audio = AudioSegment.from_file(input_audio_file)
47
+ audio.export("temp.wav", format="wav")
48
+ os.remove(input_audio_file)
49
+ return "temp.wav"
50
+ return input_audio_file
 
51
 
52
+ def synthesize_text(text: str, input_audio_file: str, language: str) -> str:
53
+ input_audio_file = convert_to_wav(input_audio_file)
54
+ tts.tts_to_file(text=text, speaker_wav=input_audio_file, language=language, file_path="./output.wav")
55
+ return "./output.wav"
56
+
57
+ @audio_processing
58
+ def process_audio(input_audio_file: str) -> str:
59
+ return input_audio_file
60
 
61
  def voice_clone(text: str, input_file: gr.File, language: str, url: gr.Audio) -> str:
62
  if input_file is not None:
 
75
  return"Error: Please select a file or enter a URL"
76
  if language not in LANGUAGES:
77
  return "Error: Invalid language selected"
78
+ output_file_path = synthesize_text(text, input_audio_file,language)
79
  return output_file_path
80
 
81
  iface = gr.Interface(