Vageesh1 commited on
Commit
308f38a
1 Parent(s): 1cb05db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -2,6 +2,7 @@ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2
  from elevenlabs import set_api_key
3
  from elevenlabs import clone, generate, play
4
  from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
 
5
  from huggingface_hub.hf_api import HfFolder
6
  HfFolder.save_token('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')
7
  access_token = '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'
@@ -22,9 +23,9 @@ def translate(text):
22
  return result
23
 
24
 
25
- def save_uploaded_file(uploaded_file, output_file_path):
26
- with open(output_file_path, "wb") as f:
27
- f.write(uploaded_file.getbuffer())
28
 
29
  def ui():
30
  st.title('Multi Lingual Voice Cloner')
@@ -34,7 +35,7 @@ def ui():
34
  audio_file = st.file_uploader("Upload an audio file that needs to be cloned", type=[ "wav,Mp4","Mp3"])
35
  if audio_file is not None:
36
  output_file_path = "./output_audio.mp3"
37
- save_uploaded_file(audio_file, output_file_path)
38
  st.success(f"Audio file saved as {output_file_path}")
39
  user_api_key = st.sidebar.text_input(
40
  label="#### Your Eleven Labs API key here 👇",
 
2
  from elevenlabs import set_api_key
3
  from elevenlabs import clone, generate, play
4
  from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
5
+ from pydub import AudioSegment
6
  from huggingface_hub.hf_api import HfFolder
7
  HfFolder.save_token('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')
8
  access_token = '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'
 
23
  return result
24
 
25
 
26
+ def save_uploaded_file_as_mp3(uploaded_file, output_file_path):
27
+ audio = AudioSegment.from_file(uploaded_file)
28
+ audio.export(output_file_path, format="mp3")
29
 
30
  def ui():
31
  st.title('Multi Lingual Voice Cloner')
 
35
  audio_file = st.file_uploader("Upload an audio file that needs to be cloned", type=[ "wav,Mp4","Mp3"])
36
  if audio_file is not None:
37
  output_file_path = "./output_audio.mp3"
38
+ save_uploaded_file_as_mp3(audio_file, output_file_path)
39
  st.success(f"Audio file saved as {output_file_path}")
40
  user_api_key = st.sidebar.text_input(
41
  label="#### Your Eleven Labs API key here 👇",