Saif Rehman Nasir commited on
Commit
8b2c674
·
1 Parent(s): 1b35ec9

Add RVC code

Browse files
Files changed (1) hide show
  1. app.py +37 -31
app.py CHANGED
@@ -12,10 +12,21 @@ client = InferenceClient(
12
  "meta-llama/Meta-Llama-3-8B-Instruct", token=os.getenv("hf_token")
13
  )
14
 
15
- # def download(filename):
16
- # object_store_url = os.getenv("OBJECT_STORE")
17
- # username = os.getenv("USERNAME")
18
- # password = os.getenv("PASSWORD")
 
 
 
 
 
 
 
 
 
 
 
19
 
20
 
21
  def process_audio(audio_data):
@@ -135,6 +146,9 @@ def respond(message, history: list[tuple[str, str]]):
135
  # elif "music" in decision_response:
136
  elif "music" in decision_response:
137
  responded_answer = message
 
 
 
138
 
139
  else:
140
  # others
@@ -181,33 +195,25 @@ def tts_part():
181
  result = client.predict(text, audio=file("siri.wav"), api_name="/predict")
182
  llama_responded = 0
183
  responded_answer = ""
184
- # else:
185
- # music_client = Client("r3gm/rvc_zero")
186
- # result_list = music_client.predict(
187
- # audio_files=[
188
- # file(
189
- # "https://github.com/gradio-app/gradio/raw/main/test/test_files/sample_file.pdf"
190
- # )
191
- # ],
192
- # file_m=file(
193
- # "https://github.com/gradio-app/gradio/raw/main/test/test_files/sample_file.pdf"
194
- # ),
195
- # pitch_alg="rmvpe+",
196
- # pitch_lvl=0,
197
- # file_index=file(
198
- # "https://github.com/gradio-app/gradio/raw/main/test/test_files/sample_file.pdf"
199
- # ),
200
- # index_inf=0.75,
201
- # r_m_f=3,
202
- # e_r=0.25,
203
- # c_b_p=0.5,
204
- # active_noise_reduce=False,
205
- # audio_effects=False,
206
- # api_name="/run",
207
- # )
208
- # result = result_list[0]
209
- # llama_responded = 0
210
- # responded_answer = ""
211
 
212
  return result
213
 
 
12
  "meta-llama/Meta-Llama-3-8B-Instruct", token=os.getenv("hf_token")
13
  )
14
 
15
+
16
+ def download(filename, directory):
17
+ object_store_url = os.getenv("OBJECT_STORE")
18
+ username = os.getenv("USERNAME")
19
+ password = os.getenv("PASSWORD")
20
+
21
+ download_url = f"{object_store_url}{directory}/{filename}"
22
+ response = requests.get(download_url, auth=(username, password))
23
+ if response.status_code == 200:
24
+ with open(filename, "wb") as file:
25
+ file.write(response.content)
26
+ print("File downloaded successfully")
27
+ else:
28
+ print(f"Failed to download file. Status code: {response.status_code}")
29
+ print(response.text)
30
 
31
 
32
  def process_audio(audio_data):
 
146
  # elif "music" in decision_response:
147
  elif "music" in decision_response:
148
  responded_answer = message
149
+ download("SiriVT.pth", "Siri")
150
+ download("added_IVF617_Flat_nprobe_1_SiriVT_v1.index", "Siri")
151
+ download("The_Lion_King_Hakuna_Matata.mp4", "songs")
152
 
153
  else:
154
  # others
 
195
  result = client.predict(text, audio=file("siri.wav"), api_name="/predict")
196
  llama_responded = 0
197
  responded_answer = ""
198
+ else:
199
+ music_client = Client("r3gm/rvc_zero")
200
+ result_list = music_client.predict(
201
+ audio_files=[file("./The_Lion_King_Hakuna_Matata.mp4")],
202
+ file_m=file("./SiriVT.pth"),
203
+ pitch_alg="rmvpe+",
204
+ pitch_lvl=0,
205
+ file_index=file("./added_IVF617_Flat_nprobe_1_SiriVT_v1.index"),
206
+ index_inf=0.75,
207
+ r_m_f=3,
208
+ e_r=0.25,
209
+ c_b_p=0.5,
210
+ active_noise_reduce=False,
211
+ audio_effects=False,
212
+ api_name="/run",
213
+ )
214
+ result = result_list[0]
215
+ llama_responded = 0
216
+ responded_answer = ""
 
 
 
 
 
 
 
 
217
 
218
  return result
219