Spaces:
Running
on
L40S
Running
on
L40S
hainazhu
commited on
Commit
·
4b156ad
1
Parent(s):
b000a9b
add infer logic
Browse files
app.py
CHANGED
@@ -64,10 +64,9 @@ def generate_song(description, lyric, prompt_audio=None):
|
|
64 |
if prompt_audio is not None:
|
65 |
print("Using prompt audio for generation")
|
66 |
|
67 |
-
|
68 |
-
audio_path = os.path.join(os.path.dirname(__file__), "sample/example.mp3")
|
69 |
-
audio_data, sample_rate = librosa.load(audio_path, sr=None) # 保持原始采样率
|
70 |
|
|
|
71 |
|
72 |
# 创建输入配置的JSON
|
73 |
input_config = {
|
@@ -75,7 +74,6 @@ def generate_song(description, lyric, prompt_audio=None):
|
|
75 |
"lyric": lyric,
|
76 |
"has_prompt_audio": prompt_audio is not None,
|
77 |
"timestamp": datetime.now().isoformat(),
|
78 |
-
"model": str(model),
|
79 |
}
|
80 |
|
81 |
return (sample_rate, audio_data), json.dumps(input_config, indent=2)
|
|
|
64 |
if prompt_audio is not None:
|
65 |
print("Using prompt audio for generation")
|
66 |
|
67 |
+
sample_rate = model.cfg.sample_rate
|
|
|
|
|
68 |
|
69 |
+
audio_data = model(description, lyric, prompt_audio).cpu().float().numpy()
|
70 |
|
71 |
# 创建输入配置的JSON
|
72 |
input_config = {
|
|
|
74 |
"lyric": lyric,
|
75 |
"has_prompt_audio": prompt_audio is not None,
|
76 |
"timestamp": datetime.now().isoformat(),
|
|
|
77 |
}
|
78 |
|
79 |
return (sample_rate, audio_data), json.dumps(input_config, indent=2)
|