| 12 | } |
| 13 | |
| 14 | async function fetchAudioViaRoute(payload: { |
| 15 | prompt: string |
| 16 | provider: Provider |
| 17 | testId?: string |
| 18 | aimockPort?: number |
| 19 | feature?: Feature |
| 20 | }): Promise<AudioGenerationResult> { |
| 21 | const response = await fetch('/api/audio', { |
| 22 | method: 'POST', |
| 23 | headers: { 'Content-Type': 'application/json' }, |
| 24 | body: JSON.stringify({ data: payload }), |
| 25 | }) |
| 26 | const body = await response.json() |
| 27 | if (!response.ok) { |
| 28 | throw new Error(body.error || `HTTP ${response.status}`) |
| 29 | } |
| 30 | return body.result as AudioGenerationResult |
| 31 | } |
| 32 | |
| 33 | export function AudioGenUI({ |
| 34 | provider, |