lord-reso commited on
Commit
2db5666
·
verified ·
1 Parent(s): 5779505

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -8,7 +8,6 @@ import numpy as np
8
  from io import BytesIO
9
  from hifigan.inference_e2e import hifi_gan_inference
10
 
11
-
12
  app = FastAPI()
13
 
14
  @app.get("/")
@@ -16,7 +15,6 @@ def read_root():
16
  data = {"Voice": "Cloning", "Status": "Success"}
17
  return JSONResponse(content=data)
18
 
19
-
20
  app.add_middleware(
21
  CORSMiddleware,
22
  allow_origins=["*"],
@@ -49,17 +47,16 @@ async def synthesize(request: Request):
49
  np.save(buffer, mel_output_data)
50
  input_mel = buffer.getvalue()
51
 
52
- hifigan_checkpoint="generator_v1"
53
 
54
  # Generate audio using Hifigan
55
- hifi_gan_inference(input_mel, hifigan_checkpoint)
56
 
57
  # Plot the waveform
58
- wave_base64 = plot_waveforms(audio_file_path)
59
 
60
  # Encode audio content as Base64
61
- with open(audio_file_path, 'rb') as audio_file:
62
- audio_base64 = base64.b64encode(audio_file.read()).decode('utf-8')
63
 
64
  # Customize the response based on the information you want to send to the frontend
65
  response_data = {
 
8
  from io import BytesIO
9
  from hifigan.inference_e2e import hifi_gan_inference
10
 
 
11
  app = FastAPI()
12
 
13
  @app.get("/")
 
15
  data = {"Voice": "Cloning", "Status": "Success"}
16
  return JSONResponse(content=data)
17
 
 
18
  app.add_middleware(
19
  CORSMiddleware,
20
  allow_origins=["*"],
 
47
  np.save(buffer, mel_output_data)
48
  input_mel = buffer.getvalue()
49
 
50
+ hifigan_checkpoint = "generator_v1"
51
 
52
  # Generate audio using Hifigan
53
+ audio_data = hifi_gan_inference(input_mel, hifigan_checkpoint)
54
 
55
  # Plot the waveform
56
+ wave_base64 = plot_waveforms(audio_data)
57
 
58
  # Encode audio content as Base64
59
+ audio_base64 = base64.b64encode(audio_data).decode('utf-8')
 
60
 
61
  # Customize the response based on the information you want to send to the frontend
62
  response_data = {