()
| 43 | const [result, setResult] = useState<AudioGenerationResult | null>(null) |
| 44 | |
| 45 | const generate = async () => { |
| 46 | if (!prompt.trim()) return |
| 47 | setIsLoading(true) |
| 48 | setError(null) |
| 49 | try { |
| 50 | const payload = { prompt, provider, testId, aimockPort, feature } |
| 51 | const next = |
| 52 | mode === 'fetcher' |
| 53 | ? await generateAudioFn({ data: payload }) |
| 54 | : await fetchAudioViaRoute(payload) |
| 55 | setResult(next as AudioGenerationResult) |
| 56 | } catch (e) { |
| 57 | setError(e instanceof Error ? e : new Error(String(e))) |
| 58 | } finally { |
| 59 | setIsLoading(false) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | const audioSrc = result |
| 64 | ? (result.audio.url ?? |
no test coverage detected