-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathae_api.py
More file actions
36 lines (30 loc) · 1.03 KB
/
Copy pathae_api.py
File metadata and controls
36 lines (30 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import requests
import os
# Configuration
AUDIO_ENGINE_URL = "http://127.0.0.1:6000/generate"
def request_music(prompt, duration=10):
"""
Call this from your GUI button.
"""
payload = {
"prompt": prompt,
"duration": duration
}
try:
print(f"Requesting audio: {prompt}...")
response = requests.post(AUDIO_ENGINE_URL, json=payload, timeout=60)
if response.status_code == 200:
data = response.json()
if data['status'] == 'SUCCESS':
print(f"Audio Ready: {data['file']}")
return data['file'] # Returns the path to the .wav
else:
print("Engine Error:", data.get('message'))
else:
print("Engine Unreachable")
except Exception as e:
print(f"Connection Failed. Is audio_engine.py running? {e}")
return None
# --- TEST (Run this line when you click your GUI button) ---
# file_path = request_music("Dark cyberpunk bassline", 5)
# if file_path: play_sound(file_path)