From c62f61516281a50fea05b7217ba6c2718045966e Mon Sep 17 00:00:00 2001 From: Jamie Pine Date: Sun, 25 Jan 2026 18:44:25 -0800 Subject: [PATCH] Implement sample audio retrieval and update playback functionality - Added a new API endpoint to serve profile sample audio files. - Introduced a method in the apiClient to generate sample audio URLs. - Refactored the SampleList component to utilize the new API for audio playback, enhancing the user experience. - Cleaned up unused imports and optimized the handlePlay function for better performance. --- app/src/App.tsx | 2 +- .../components/VoiceProfiles/SampleList.tsx | 11 ++++------ app/src/lib/api/client.ts | 4 ++++ backend/main.py | 20 ++++++++++++++++++ tauri/src-tauri/gen/Assets.car | Bin 3847048 -> 3847048 bytes 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/app/src/App.tsx b/app/src/App.tsx index 0fda4e50..5b4fbce6 100644 --- a/app/src/App.tsx +++ b/app/src/App.tsx @@ -100,7 +100,7 @@ function App() {
-
+
{activeTab === 'settings' ? ( diff --git a/app/src/components/VoiceProfiles/SampleList.tsx b/app/src/components/VoiceProfiles/SampleList.tsx index 0d82b926..ae2b5bb7 100644 --- a/app/src/components/VoiceProfiles/SampleList.tsx +++ b/app/src/components/VoiceProfiles/SampleList.tsx @@ -1,10 +1,9 @@ import { Plus, Trash2, Play } from 'lucide-react'; import { useState } from 'react'; import { Button } from '@/components/ui/button'; -import { useToast } from '@/components/ui/use-toast'; import { useDeleteSample, useProfileSamples } from '@/lib/hooks/useProfiles'; -import { useServerStore } from '@/stores/serverStore'; import { usePlayerStore } from '@/stores/playerStore'; +import { apiClient } from '@/lib/api/client'; import { SampleUpload } from './SampleUpload'; interface SampleListProps { @@ -15,8 +14,6 @@ export function SampleList({ profileId }: SampleListProps) { const { data: samples, isLoading } = useProfileSamples(profileId); const deleteSample = useDeleteSample(); const [uploadOpen, setUploadOpen] = useState(false); - const { toast } = useToast(); - const serverUrl = useServerStore((state) => state.serverUrl); const setAudio = usePlayerStore((state) => state.setAudio); const currentAudioId = usePlayerStore((state) => state.audioId); const isPlaying = usePlayerStore((state) => state.isPlaying); @@ -27,8 +24,8 @@ export function SampleList({ profileId }: SampleListProps) { } }; - const handlePlay = (audioPath: string, referenceText: string, sampleId: string) => { - const audioUrl = `${serverUrl}${audioPath}`; + const handlePlay = (referenceText: string, sampleId: string) => { + const audioUrl = apiClient.getSampleUrl(sampleId); setAudio(audioUrl, sampleId, referenceText.substring(0, 50)); }; @@ -65,7 +62,7 @@ export function SampleList({ profileId }: SampleListProps) {