zzk1st commited on
Commit
3fbeda5
1 Parent(s): 5bd33c2

Changed localhost to 0.0.0.0

Browse files
Files changed (3) hide show
  1. APIs.py +6 -5
  2. config.yaml +1 -1
  3. ui_client.py +3 -3
APIs.py CHANGED
@@ -16,6 +16,7 @@ with open('config.yaml', 'r') as file:
16
  config = yaml.safe_load(file)
17
  service_port = config['Service-Port']
18
  enable_sr = config['Speech-Restoration']['Enable']
 
19
 
20
 
21
  def LOUDNESS_NORM(audio, sr=32000, volumn=-25):
@@ -111,7 +112,7 @@ def COMPUTE_LEN(wav):
111
 
112
  @retry(stop_max_attempt_number=5, wait_fixed=2000)
113
  def TTM(text, length=10, volume=-28, out_wav='out.wav'):
114
- url = f'http://127.0.0.1:{service_port}/generate_music'
115
  data = {
116
  'text': f'{text}',
117
  'length': f'{length}',
@@ -129,7 +130,7 @@ def TTM(text, length=10, volume=-28, out_wav='out.wav'):
129
 
130
  @retry(stop_max_attempt_number=5, wait_fixed=2000)
131
  def TTA(text, length=5, volume=-35, out_wav='out.wav'):
132
- url = f'http://127.0.0.1:{service_port}/generate_audio'
133
  data = {
134
  'text': f'{text}',
135
  'length': f'{length}',
@@ -148,7 +149,7 @@ def TTA(text, length=5, volume=-35, out_wav='out.wav'):
148
 
149
  @retry(stop_max_attempt_number=5, wait_fixed=2000)
150
  def TTS(text, speaker='news_anchor', volume=-20, out_wav='out.wav', enhanced=enable_sr, speaker_id='', speaker_npz=''):
151
- url = f'http://127.0.0.1:{service_port}/generate_speech'
152
  data = {
153
  'text': f'{text}',
154
  'speaker_id': f'{speaker_id}',
@@ -171,7 +172,7 @@ def TTS(text, speaker='news_anchor', volume=-20, out_wav='out.wav', enhanced=ena
171
 
172
  @retry(stop_max_attempt_number=5, wait_fixed=2000)
173
  def SR(processfile):
174
- url = f'http://127.0.0.1:{service_port}/fix_audio'
175
  data = {'processfile': f'{processfile}'}
176
 
177
  response = requests.post(url, json=data)
@@ -185,7 +186,7 @@ def SR(processfile):
185
 
186
  @retry(stop_max_attempt_number=5, wait_fixed=2000)
187
  def VP(wav_path, out_dir):
188
- url = f'http://127.0.0.1:{service_port}/parse_voice'
189
  data = {
190
  'wav_path': f'{wav_path}',
191
  'out_dir':f'{out_dir}'
 
16
  config = yaml.safe_load(file)
17
  service_port = config['Service-Port']
18
  enable_sr = config['Speech-Restoration']['Enable']
19
+ localhost_addr = '0.0.0.0'
20
 
21
 
22
  def LOUDNESS_NORM(audio, sr=32000, volumn=-25):
 
112
 
113
  @retry(stop_max_attempt_number=5, wait_fixed=2000)
114
  def TTM(text, length=10, volume=-28, out_wav='out.wav'):
115
+ url = f'http://{localhost_addr}:{service_port}/generate_music'
116
  data = {
117
  'text': f'{text}',
118
  'length': f'{length}',
 
130
 
131
  @retry(stop_max_attempt_number=5, wait_fixed=2000)
132
  def TTA(text, length=5, volume=-35, out_wav='out.wav'):
133
+ url = f'http://{localhost_addr}:{service_port}/generate_audio'
134
  data = {
135
  'text': f'{text}',
136
  'length': f'{length}',
 
149
 
150
  @retry(stop_max_attempt_number=5, wait_fixed=2000)
151
  def TTS(text, speaker='news_anchor', volume=-20, out_wav='out.wav', enhanced=enable_sr, speaker_id='', speaker_npz=''):
152
+ url = f'http://{localhost_addr}:{service_port}/generate_speech'
153
  data = {
154
  'text': f'{text}',
155
  'speaker_id': f'{speaker_id}',
 
172
 
173
  @retry(stop_max_attempt_number=5, wait_fixed=2000)
174
  def SR(processfile):
175
+ url = f'http://{localhost_addr}:{service_port}/fix_audio'
176
  data = {'processfile': f'{processfile}'}
177
 
178
  response = requests.post(url, json=data)
 
186
 
187
  @retry(stop_max_attempt_number=5, wait_fixed=2000)
188
  def VP(wav_path, out_dir):
189
+ url = f'http://{localhost_addr}:{service_port}/parse_voice'
190
  data = {
191
  'wav_path': f'{wav_path}',
192
  'out_dir':f'{out_dir}'
config.yaml CHANGED
@@ -16,6 +16,6 @@ Voice-Parser:
16
  # HuBERT
17
  device: 'cpu'
18
 
19
- Service-Port: 5000
20
 
21
  OpenAI-Key: ''
 
16
  # HuBERT
17
  device: 'cpu'
18
 
19
+ Service-Port: 8021
20
 
21
  OpenAI-Key: ''
ui_client.py CHANGED
@@ -48,7 +48,7 @@ def generate_script_fn(instruction, _state: gr.State):
48
  json_script = generate_json_file(session_id, instruction, api_key)
49
  table_text = convert_json_to_md(json_script)
50
  except Exception as e:
51
- gr.Warning(str(e))
52
  print(f"Generating script error: {str(e)}")
53
  traceback.print_exc()
54
  return [
@@ -92,7 +92,7 @@ def generate_audio_fn(state):
92
  except Exception as e:
93
  print(f"Generation audio error: {str(e)}")
94
  traceback.print_exc()
95
- gr.Warning(str(e))
96
 
97
  return [
98
  None,
@@ -194,7 +194,7 @@ def add_voice_preset(vp_id, vp_desc, file, ui_state, added_voice_preset):
194
  except Exception as exception:
195
  print(exception)
196
  traceback.print_exc()
197
- gr.Warning(str(exception))
198
 
199
  # After added
200
  dataframe = get_voice_preset_to_list(ui_state)
 
48
  json_script = generate_json_file(session_id, instruction, api_key)
49
  table_text = convert_json_to_md(json_script)
50
  except Exception as e:
51
+ gr.Warning(str(e) + traceback.format_exc())
52
  print(f"Generating script error: {str(e)}")
53
  traceback.print_exc()
54
  return [
 
92
  except Exception as e:
93
  print(f"Generation audio error: {str(e)}")
94
  traceback.print_exc()
95
+ gr.Warning(str(e) + traceback.format_exc())
96
 
97
  return [
98
  None,
 
194
  except Exception as exception:
195
  print(exception)
196
  traceback.print_exc()
197
+ gr.Warning(str(exception) + traceback.format_exc())
198
 
199
  # After added
200
  dataframe = get_voice_preset_to_list(ui_state)