Brasd99 commited on
Commit
c8c664f
1 Parent(s): 5202de8
Files changed (2) hide show
  1. app.py +8 -4
  2. config.json +1 -2
app.py CHANGED
@@ -5,6 +5,7 @@ import streamlit as st
5
  import tempfile
6
  import os
7
  import json
 
8
 
9
  with open('config.json', 'r') as f:
10
  config = json.load(f)
@@ -13,7 +14,6 @@ APP_NAME = config['APP_NAME']
13
  APP_LOGO = config['APP_LOGO']
14
  APP_DESCRIPTION = config['APP_DESCRIPTION']
15
  LANGUAGES_URL = config['LANGUAGES_URL']
16
- OUTPUT_FILENAME = config['OUTPUT_FILENAME']
17
 
18
  def contains_only_ascii(input_string):
19
  return all(ord(char) < 128 for char in input_string)
@@ -69,6 +69,10 @@ if input_wav:
69
  progress_bar = st.progress(0)
70
  status_text = st.empty()
71
 
 
 
 
 
72
  temp_file = create_temp_file(input_wav)
73
 
74
  iso_code = iso_languages[language]
@@ -82,16 +86,16 @@ if input_wav:
82
  api.tts_with_vc_to_file(
83
  prompt,
84
  speaker_wav=temp_file.name,
85
- file_path=OUTPUT_FILENAME
86
  )
87
 
88
  remove_temp_file(temp_file)
89
 
90
- audio_file = open(OUTPUT_FILENAME, 'rb')
91
  audio_bytes = audio_file.read()
92
 
93
  update_progress(100, 'Audio generated successfully!')
94
 
95
  st.audio(audio_bytes, format='audio/wav')
96
 
97
- st.download_button('Download WAV', data=audio_bytes, file_name='file.wav')
 
5
  import tempfile
6
  import os
7
  import json
8
+ import datetime
9
 
10
  with open('config.json', 'r') as f:
11
  config = json.load(f)
 
14
  APP_LOGO = config['APP_LOGO']
15
  APP_DESCRIPTION = config['APP_DESCRIPTION']
16
  LANGUAGES_URL = config['LANGUAGES_URL']
 
17
 
18
  def contains_only_ascii(input_string):
19
  return all(ord(char) < 128 for char in input_string)
 
69
  progress_bar = st.progress(0)
70
  status_text = st.empty()
71
 
72
+ current_datetime = datetime.datetime.now()
73
+ formatted_datetime = current_datetime.strftime("%Y-%m-%d_%H%M%S")
74
+ output_filename = f"recording_{formatted_datetime}.wav"
75
+
76
  temp_file = create_temp_file(input_wav)
77
 
78
  iso_code = iso_languages[language]
 
86
  api.tts_with_vc_to_file(
87
  prompt,
88
  speaker_wav=temp_file.name,
89
+ file_path=output_filename
90
  )
91
 
92
  remove_temp_file(temp_file)
93
 
94
+ audio_file = open(output_filename, 'rb')
95
  audio_bytes = audio_file.read()
96
 
97
  update_progress(100, 'Audio generated successfully!')
98
 
99
  st.audio(audio_bytes, format='audio/wav')
100
 
101
+ st.download_button('Download WAV', data=audio_bytes, file_name='output.wav')
config.json CHANGED
@@ -2,6 +2,5 @@
2
  "APP_NAME": "TTS-Voice-Cloner",
3
  "APP_LOGO": "https://raw.githubusercontent.com/coqui-ai/TTS/main/images/coqui-log-green-TTS.png",
4
  "APP_DESCRIPTION": "Simple app that uses [Coqui TTS](https://github.com/coqui-ai/TTS) library to clone your voice!",
5
- "LANGUAGES_URL": "https://dl.fbaipublicfiles.com/mms/tts/all-tts-languages.html",
6
- "OUTPUT_FILENAME": "output.wav"
7
  }
 
2
  "APP_NAME": "TTS-Voice-Cloner",
3
  "APP_LOGO": "https://raw.githubusercontent.com/coqui-ai/TTS/main/images/coqui-log-green-TTS.png",
4
  "APP_DESCRIPTION": "Simple app that uses [Coqui TTS](https://github.com/coqui-ai/TTS) library to clone your voice!",
5
+ "LANGUAGES_URL": "https://dl.fbaipublicfiles.com/mms/tts/all-tts-languages.html"
 
6
  }