mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-09-29 07:05:14 -07:00
chore: drop dead code, export routeTree
Removes the orphaned generated OpenAPI client (superseded by the hand-written client.ts), the unrouted AudioTab, and app/'s unused standalone entry (main.tsx, index.html, vite.config) — app/ is a shared library consumed by web/ and tauri/. routeTree is exported so tests can build routers over memory history.
This commit is contained in:
@@ -1,29 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>voicebox</title>
|
|
||||||
<script>
|
|
||||||
(function () {
|
|
||||||
try {
|
|
||||||
var theme = 'system';
|
|
||||||
var raw = localStorage.getItem('voicebox-ui');
|
|
||||||
if (raw) {
|
|
||||||
var parsed = JSON.parse(raw);
|
|
||||||
if (parsed && parsed.state && parsed.state.theme) theme = parsed.state.theme;
|
|
||||||
}
|
|
||||||
var resolved = theme === 'system'
|
|
||||||
? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')
|
|
||||||
: theme;
|
|
||||||
if (resolved === 'dark') document.documentElement.classList.add('dark');
|
|
||||||
} catch (_) {}
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="root"></div>
|
|
||||||
<script type="module" src="/src/main.tsx"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -4,10 +4,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
|
||||||
"build": "vite build",
|
|
||||||
"typecheck": "tsc -p tsconfig.json --noEmit",
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
||||||
"preview": "vite preview",
|
|
||||||
"lint": "biome lint src",
|
"lint": "biome lint src",
|
||||||
"lint:fix": "biome lint --write src",
|
"lint:fix": "biome lint --write src",
|
||||||
"format": "biome format --write src",
|
"format": "biome format --write src",
|
||||||
|
|||||||
@@ -1,675 +0,0 @@
|
|||||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
||||||
import { Check, CheckCircle2, Edit, Plus, Speaker, Trash2 } from 'lucide-react';
|
|
||||||
import { useState } from 'react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
import { Badge } from '@/components/ui/badge';
|
|
||||||
import { Button } from '@/components/ui/button';
|
|
||||||
import {
|
|
||||||
Dialog,
|
|
||||||
DialogContent,
|
|
||||||
DialogDescription,
|
|
||||||
DialogFooter,
|
|
||||||
DialogHeader,
|
|
||||||
DialogTitle,
|
|
||||||
} from '@/components/ui/dialog';
|
|
||||||
import { Input } from '@/components/ui/input';
|
|
||||||
import { Label } from '@/components/ui/label';
|
|
||||||
import {
|
|
||||||
Select,
|
|
||||||
SelectContent,
|
|
||||||
SelectItem,
|
|
||||||
SelectTrigger,
|
|
||||||
SelectValue,
|
|
||||||
} from '@/components/ui/select';
|
|
||||||
import { apiClient } from '@/lib/api/client';
|
|
||||||
import { BOTTOM_SAFE_AREA_PADDING } from '@/lib/constants/ui';
|
|
||||||
import { cn } from '@/lib/utils/cn';
|
|
||||||
import { usePlatform } from '@/platform/PlatformContext';
|
|
||||||
import { usePlayerStore } from '@/stores/playerStore';
|
|
||||||
|
|
||||||
interface AudioDevice {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
is_default: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function AudioTab() {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const platform = usePlatform();
|
|
||||||
const [createDialogOpen, setCreateDialogOpen] = useState(false);
|
|
||||||
const [editingChannel, setEditingChannel] = useState<string | null>(null);
|
|
||||||
const [selectedChannelId, setSelectedChannelId] = useState<string | null>(null);
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const audioUrl = usePlayerStore((state) => state.audioUrl);
|
|
||||||
const isPlayerVisible = !!audioUrl;
|
|
||||||
|
|
||||||
const { data: channels, isLoading: channelsLoading } = useQuery({
|
|
||||||
queryKey: ['channels'],
|
|
||||||
queryFn: () => apiClient.listChannels(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const { data: devices, isLoading: devicesLoading } = useQuery({
|
|
||||||
queryKey: ['audio-devices'],
|
|
||||||
queryFn: async () => {
|
|
||||||
if (!platform.metadata.isTauri) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return await platform.audio.listOutputDevices();
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to list audio devices:', error);
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
enabled: platform.metadata.isTauri,
|
|
||||||
});
|
|
||||||
|
|
||||||
const { data: profiles } = useQuery({
|
|
||||||
queryKey: ['profiles'],
|
|
||||||
queryFn: () => apiClient.listProfiles(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const createChannel = useMutation({
|
|
||||||
mutationFn: (data: { name: string; device_ids: string[] }) => apiClient.createChannel(data),
|
|
||||||
onSuccess: () => {
|
|
||||||
queryClient.invalidateQueries({ queryKey: ['channels'] });
|
|
||||||
setCreateDialogOpen(false);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const updateChannel = useMutation({
|
|
||||||
mutationFn: ({
|
|
||||||
channelId,
|
|
||||||
data,
|
|
||||||
}: {
|
|
||||||
channelId: string;
|
|
||||||
data: { name?: string; device_ids?: string[] };
|
|
||||||
}) => apiClient.updateChannel(channelId, data),
|
|
||||||
onSuccess: () => {
|
|
||||||
queryClient.invalidateQueries({ queryKey: ['channels'] });
|
|
||||||
queryClient.invalidateQueries({ queryKey: ['profile-channels'] });
|
|
||||||
setEditingChannel(null);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const deleteChannel = useMutation({
|
|
||||||
mutationFn: (channelId: string) => apiClient.deleteChannel(channelId),
|
|
||||||
onSuccess: () => {
|
|
||||||
queryClient.invalidateQueries({ queryKey: ['channels'] });
|
|
||||||
queryClient.invalidateQueries({ queryKey: ['profile-channels'] });
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const { data: channelVoices } = useQuery({
|
|
||||||
queryKey: ['channel-voices', editingChannel],
|
|
||||||
queryFn: async () => {
|
|
||||||
if (!editingChannel) return { profile_ids: [] };
|
|
||||||
return apiClient.getChannelVoices(editingChannel);
|
|
||||||
},
|
|
||||||
enabled: !!editingChannel,
|
|
||||||
});
|
|
||||||
|
|
||||||
const setChannelVoices = useMutation({
|
|
||||||
mutationFn: ({ channelId, profileIds }: { channelId: string; profileIds: string[] }) =>
|
|
||||||
apiClient.setChannelVoices(channelId, profileIds),
|
|
||||||
onSuccess: () => {
|
|
||||||
queryClient.invalidateQueries({ queryKey: ['channel-voices'] });
|
|
||||||
queryClient.invalidateQueries({ queryKey: ['profile-channels'] });
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (channelsLoading || devicesLoading) {
|
|
||||||
return (
|
|
||||||
<div className="flex items-center justify-center h-full">
|
|
||||||
<div className="text-muted-foreground">{t('audioChannels.loading')}</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleChannelDelete = async (e: React.MouseEvent, channelId: string) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
if (await confirm(t('audioChannels.confirmDelete'))) {
|
|
||||||
deleteChannel.mutate(channelId);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const allChannels = channels || [];
|
|
||||||
const allDevices = devices || [];
|
|
||||||
const selectedChannel = selectedChannelId
|
|
||||||
? allChannels.find((c) => c.id === selectedChannelId)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="h-full flex flex-col">
|
|
||||||
<div className="flex items-center justify-between mb-6 shrink-0">
|
|
||||||
<h2 className="text-2xl font-bold">{t('audioChannels.title')}</h2>
|
|
||||||
<Button onClick={() => setCreateDialogOpen(true)}>
|
|
||||||
<Plus className="h-4 w-4 mr-2" />
|
|
||||||
{t('audioChannels.newChannel')}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6 h-full min-h-0">
|
|
||||||
{/* Left Column - Channels */}
|
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
'flex flex-col min-h-0 overflow-y-auto',
|
|
||||||
isPlayerVisible && BOTTOM_SAFE_AREA_PADDING,
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{allChannels.length === 0 ? (
|
|
||||||
<div className="flex flex-col items-center justify-center py-12 border-2 border-dashed border-muted rounded-md">
|
|
||||||
<Speaker className="h-12 w-12 text-muted-foreground mb-4" />
|
|
||||||
<p className="text-muted-foreground mb-4">{t('audioChannels.empty.message')}</p>
|
|
||||||
<Button onClick={() => setCreateDialogOpen(true)}>
|
|
||||||
<Plus className="h-4 w-4 mr-2" />
|
|
||||||
{t('audioChannels.empty.action')}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="space-y-3">
|
|
||||||
{allChannels.map((channel) => {
|
|
||||||
const isSelected = selectedChannelId === channel.id;
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
key={channel.id}
|
|
||||||
type="button"
|
|
||||||
className={cn(
|
|
||||||
'group border rounded-lg p-4 transition-colors cursor-pointer text-left w-full',
|
|
||||||
isSelected && 'ring-2 ring-primary bg-primary/5 border-primary',
|
|
||||||
)}
|
|
||||||
onClick={() => setSelectedChannelId(isSelected ? null : channel.id)}
|
|
||||||
>
|
|
||||||
<div className="flex items-start justify-between gap-4">
|
|
||||||
<div className="flex-1 min-w-0">
|
|
||||||
<div className="flex items-center gap-2 mb-3">
|
|
||||||
<div className="h-8 w-8 rounded-lg bg-muted flex items-center justify-center shrink-0">
|
|
||||||
<Speaker className="h-4 w-4 text-muted-foreground" />
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center gap-2 min-w-0">
|
|
||||||
<h3 className="font-semibold text-base truncate">{channel.name}</h3>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="space-y-2.5 ml-10">
|
|
||||||
<div>
|
|
||||||
<div className="text-xs font-medium text-muted-foreground mb-1">
|
|
||||||
{t('audioChannels.labels.outputDevices')}
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-wrap gap-1.5">
|
|
||||||
{channel.device_ids.length > 0
|
|
||||||
? channel.device_ids.map((deviceId) => {
|
|
||||||
const device = allDevices.find((d) => d.id === deviceId);
|
|
||||||
return (
|
|
||||||
<Badge
|
|
||||||
key={deviceId}
|
|
||||||
variant="outline"
|
|
||||||
className="text-xs font-normal"
|
|
||||||
>
|
|
||||||
{device?.name || deviceId}
|
|
||||||
</Badge>
|
|
||||||
);
|
|
||||||
})
|
|
||||||
: (() => {
|
|
||||||
const defaultDevice = allDevices.find((d) => d.is_default);
|
|
||||||
return defaultDevice ? (
|
|
||||||
<Badge variant="outline" className="text-xs font-normal">
|
|
||||||
{defaultDevice.name}
|
|
||||||
</Badge>
|
|
||||||
) : null;
|
|
||||||
})()}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<div className="text-xs font-medium text-muted-foreground mb-1">
|
|
||||||
{t('audioChannels.labels.assignedVoices')}
|
|
||||||
</div>
|
|
||||||
<ChannelVoicesList channelId={channel.id} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{!channel.is_default && (
|
|
||||||
<div className="flex gap-1 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity">
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
className="h-8 w-8 p-0"
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
setEditingChannel(channel.id);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Edit className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
className="h-8 w-8 p-0"
|
|
||||||
onClick={(e) => handleChannelDelete(e, channel.id)}
|
|
||||||
>
|
|
||||||
<Trash2 className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Right Column - Available Devices */}
|
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
'flex flex-col min-h-0 overflow-y-auto',
|
|
||||||
isPlayerVisible && BOTTOM_SAFE_AREA_PADDING,
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<div className="shrink-0 mb-4">
|
|
||||||
<h3 className="text-lg font-semibold">{t('audioChannels.devices.title')}</h3>
|
|
||||||
<p className="text-sm text-muted-foreground mt-1">
|
|
||||||
{selectedChannelId
|
|
||||||
? selectedChannel?.is_default
|
|
||||||
? t('audioChannels.devices.defaultNote')
|
|
||||||
: t('audioChannels.devices.toggleHint')
|
|
||||||
: t('audioChannels.devices.selectHint')}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
{allDevices.length > 0 ? (
|
|
||||||
<div className="space-y-2">
|
|
||||||
{allDevices.map((device) => {
|
|
||||||
const isConnected =
|
|
||||||
selectedChannelId &&
|
|
||||||
selectedChannel &&
|
|
||||||
(selectedChannel.device_ids.length === 0
|
|
||||||
? device.is_default
|
|
||||||
: selectedChannel.device_ids.includes(device.id));
|
|
||||||
const canToggle =
|
|
||||||
selectedChannelId && selectedChannel && !selectedChannel.is_default;
|
|
||||||
|
|
||||||
const handleDeviceClick = () => {
|
|
||||||
if (!canToggle || !selectedChannel) return;
|
|
||||||
|
|
||||||
const currentDeviceIds = selectedChannel.device_ids;
|
|
||||||
const newDeviceIds = isConnected
|
|
||||||
? currentDeviceIds.filter((id) => id !== device.id)
|
|
||||||
: [...currentDeviceIds, device.id];
|
|
||||||
|
|
||||||
updateChannel.mutate({
|
|
||||||
channelId: selectedChannelId,
|
|
||||||
data: { device_ids: newDeviceIds },
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
key={device.id}
|
|
||||||
type="button"
|
|
||||||
onClick={handleDeviceClick}
|
|
||||||
disabled={!canToggle}
|
|
||||||
className={cn(
|
|
||||||
'flex items-center gap-2 text-sm p-3 rounded-lg border transition-colors text-left w-full',
|
|
||||||
isConnected
|
|
||||||
? 'bg-primary/10 border-primary ring-1 ring-primary/20'
|
|
||||||
: 'hover:bg-muted/50',
|
|
||||||
!canToggle && 'cursor-default opacity-60',
|
|
||||||
canToggle && 'cursor-pointer',
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{canToggle ? (
|
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
'h-4 w-4 rounded border-2 flex items-center justify-center shrink-0',
|
|
||||||
isConnected ? 'bg-accent border-accent' : 'border-muted-foreground/30',
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{isConnected && <Check className="h-3 w-3 text-accent-foreground" />}
|
|
||||||
</div>
|
|
||||||
) : device.is_default ? (
|
|
||||||
<CheckCircle2 className="h-4 w-4 text-primary shrink-0" />
|
|
||||||
) : null}
|
|
||||||
<span className={cn('truncate flex-1', device.is_default && 'font-medium')}>
|
|
||||||
{device.name}
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="flex flex-col items-center justify-center py-12 border-2 border-dashed border-muted rounded-md">
|
|
||||||
<CheckCircle2 className="h-12 w-12 text-muted-foreground mb-4" />
|
|
||||||
<p className="text-muted-foreground text-center">
|
|
||||||
{platform.metadata.isTauri
|
|
||||||
? t('audioChannels.devices.empty')
|
|
||||||
: t('audioChannels.devices.requiresTauri')}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Create Channel Dialog */}
|
|
||||||
<CreateChannelDialog
|
|
||||||
open={createDialogOpen}
|
|
||||||
onOpenChange={setCreateDialogOpen}
|
|
||||||
devices={devices || []}
|
|
||||||
onCreate={(name, deviceIds) => {
|
|
||||||
createChannel.mutate({ name, device_ids: deviceIds });
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Edit Channel Dialog */}
|
|
||||||
{editingChannel &&
|
|
||||||
(() => {
|
|
||||||
const channel = channels?.find((c) => c.id === editingChannel);
|
|
||||||
return channel ? (
|
|
||||||
<EditChannelDialog
|
|
||||||
open={!!editingChannel}
|
|
||||||
onOpenChange={(open) => !open && setEditingChannel(null)}
|
|
||||||
channel={channel}
|
|
||||||
devices={devices || []}
|
|
||||||
profiles={profiles || []}
|
|
||||||
channelVoices={channelVoices?.profile_ids || []}
|
|
||||||
onUpdate={(name, deviceIds) => {
|
|
||||||
updateChannel.mutate({
|
|
||||||
channelId: editingChannel,
|
|
||||||
data: { name, device_ids: deviceIds },
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
onSetVoices={(profileIds) => {
|
|
||||||
setChannelVoices.mutate({
|
|
||||||
channelId: editingChannel,
|
|
||||||
profileIds,
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
) : null;
|
|
||||||
})()}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function ChannelVoicesList({ channelId }: { channelId: string }) {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const { data: voices } = useQuery({
|
|
||||||
queryKey: ['channel-voices', channelId],
|
|
||||||
queryFn: () => apiClient.getChannelVoices(channelId),
|
|
||||||
});
|
|
||||||
|
|
||||||
const { data: profiles } = useQuery({
|
|
||||||
queryKey: ['profiles'],
|
|
||||||
queryFn: () => apiClient.listProfiles(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const voiceNames =
|
|
||||||
voices?.profile_ids.map((id) => profiles?.find((p) => p.id === id)?.name).filter(Boolean) || [];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex flex-wrap gap-1.5">
|
|
||||||
{voiceNames.length > 0 ? (
|
|
||||||
voiceNames.map((name) => (
|
|
||||||
<Badge key={name} variant="outline" className="text-xs font-normal">
|
|
||||||
{name}
|
|
||||||
</Badge>
|
|
||||||
))
|
|
||||||
) : (
|
|
||||||
<span className="text-sm text-muted-foreground">{t('audioChannels.noVoicesAssigned')}</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CreateChannelDialogProps {
|
|
||||||
open: boolean;
|
|
||||||
onOpenChange: (open: boolean) => void;
|
|
||||||
devices: AudioDevice[];
|
|
||||||
onCreate: (name: string, deviceIds: string[]) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
function CreateChannelDialog({ open, onOpenChange, devices, onCreate }: CreateChannelDialogProps) {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const [name, setName] = useState('');
|
|
||||||
const [selectedDevices, setSelectedDevices] = useState<string[]>([]);
|
|
||||||
|
|
||||||
const handleSubmit = () => {
|
|
||||||
if (name.trim()) {
|
|
||||||
onCreate(name.trim(), selectedDevices);
|
|
||||||
setName('');
|
|
||||||
setSelectedDevices([]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
||||||
<DialogContent>
|
|
||||||
<DialogHeader>
|
|
||||||
<DialogTitle>{t('audioChannels.createDialog.title')}</DialogTitle>
|
|
||||||
<DialogDescription>{t('audioChannels.createDialog.description')}</DialogDescription>
|
|
||||||
</DialogHeader>
|
|
||||||
<div className="space-y-4">
|
|
||||||
<div>
|
|
||||||
<Label htmlFor="channel-name">{t('audioChannels.fields.name')}</Label>
|
|
||||||
<Input
|
|
||||||
id="channel-name"
|
|
||||||
value={name}
|
|
||||||
onChange={(e) => setName(e.target.value)}
|
|
||||||
placeholder={t('audioChannels.fields.namePlaceholder')}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<Label>{t('audioChannels.labels.outputDevices')}</Label>
|
|
||||||
<Select
|
|
||||||
value={selectedDevices[0] || ''}
|
|
||||||
onValueChange={(value) => {
|
|
||||||
if (value && !selectedDevices.includes(value)) {
|
|
||||||
setSelectedDevices([...selectedDevices, value]);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<SelectTrigger>
|
|
||||||
<SelectValue placeholder={t('audioChannels.selectDevice')} />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
{devices.map((device) => (
|
|
||||||
<SelectItem key={device.id} value={device.id}>
|
|
||||||
{device.name} {device.is_default && `(${t('audioChannels.defaultSuffix')})`}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
{selectedDevices.length > 0 && (
|
|
||||||
<div className="mt-2 space-y-1">
|
|
||||||
{selectedDevices.map((deviceId) => {
|
|
||||||
const device = devices.find((d) => d.id === deviceId);
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={deviceId}
|
|
||||||
className="flex items-center justify-between text-sm bg-muted p-2 rounded"
|
|
||||||
>
|
|
||||||
<span>{device?.name || deviceId}</span>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
onClick={() =>
|
|
||||||
setSelectedDevices(selectedDevices.filter((id) => id !== deviceId))
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Trash2 className="h-3 w-3" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<DialogFooter>
|
|
||||||
<Button variant="outline" onClick={() => onOpenChange(false)}>
|
|
||||||
{t('common.cancel')}
|
|
||||||
</Button>
|
|
||||||
<Button onClick={handleSubmit} disabled={!name.trim()}>
|
|
||||||
{t('audioChannels.createDialog.action')}
|
|
||||||
</Button>
|
|
||||||
</DialogFooter>
|
|
||||||
</DialogContent>
|
|
||||||
</Dialog>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface EditChannelDialogProps {
|
|
||||||
open: boolean;
|
|
||||||
onOpenChange: (open: boolean) => void;
|
|
||||||
channel: {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
device_ids: string[];
|
|
||||||
};
|
|
||||||
devices: AudioDevice[];
|
|
||||||
profiles: Array<{ id: string; name: string }>;
|
|
||||||
channelVoices: string[];
|
|
||||||
onUpdate: (name: string, deviceIds: string[]) => void;
|
|
||||||
onSetVoices: (profileIds: string[]) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
function EditChannelDialog({
|
|
||||||
open,
|
|
||||||
onOpenChange,
|
|
||||||
channel,
|
|
||||||
devices,
|
|
||||||
profiles,
|
|
||||||
channelVoices,
|
|
||||||
onUpdate,
|
|
||||||
onSetVoices,
|
|
||||||
}: EditChannelDialogProps) {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const [name, setName] = useState(channel.name);
|
|
||||||
const [selectedDevices, setSelectedDevices] = useState<string[]>(channel.device_ids);
|
|
||||||
const [selectedVoices, setSelectedVoices] = useState<string[]>(channelVoices);
|
|
||||||
|
|
||||||
const handleSubmit = () => {
|
|
||||||
if (name.trim()) {
|
|
||||||
onUpdate(name.trim(), selectedDevices);
|
|
||||||
onSetVoices(selectedVoices);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
||||||
<DialogContent className="max-w-2xl">
|
|
||||||
<DialogHeader>
|
|
||||||
<DialogTitle>{t('audioChannels.editDialog.title')}</DialogTitle>
|
|
||||||
<DialogDescription>{t('audioChannels.editDialog.description')}</DialogDescription>
|
|
||||||
</DialogHeader>
|
|
||||||
<div className="space-y-4">
|
|
||||||
<div>
|
|
||||||
<Label htmlFor="edit-channel-name">{t('audioChannels.fields.name')}</Label>
|
|
||||||
<Input id="edit-channel-name" value={name} onChange={(e) => setName(e.target.value)} />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<Label>{t('audioChannels.labels.outputDevices')}</Label>
|
|
||||||
<Select
|
|
||||||
value=""
|
|
||||||
onValueChange={(value) => {
|
|
||||||
if (value && !selectedDevices.includes(value)) {
|
|
||||||
setSelectedDevices([...selectedDevices, value]);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<SelectTrigger>
|
|
||||||
<SelectValue placeholder={t('audioChannels.addDevice')} />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
{devices.map((device) => (
|
|
||||||
<SelectItem key={device.id} value={device.id}>
|
|
||||||
{device.name} {device.is_default && `(${t('audioChannels.defaultSuffix')})`}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
{selectedDevices.length > 0 && (
|
|
||||||
<div className="mt-2 space-y-1">
|
|
||||||
{selectedDevices.map((deviceId) => {
|
|
||||||
const device = devices.find((d) => d.id === deviceId);
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={deviceId}
|
|
||||||
className="flex items-center justify-between text-sm bg-muted p-2 rounded"
|
|
||||||
>
|
|
||||||
<span>{device?.name || deviceId}</span>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
onClick={() =>
|
|
||||||
setSelectedDevices(selectedDevices.filter((id) => id !== deviceId))
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Trash2 className="h-3 w-3" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<Label>{t('audioChannels.labels.assignedVoices')}</Label>
|
|
||||||
<Select
|
|
||||||
value=""
|
|
||||||
onValueChange={(value) => {
|
|
||||||
if (value && !selectedVoices.includes(value)) {
|
|
||||||
setSelectedVoices([...selectedVoices, value]);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<SelectTrigger>
|
|
||||||
<SelectValue placeholder={t('audioChannels.addVoice')} />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
{profiles.map((profile) => (
|
|
||||||
<SelectItem key={profile.id} value={profile.id}>
|
|
||||||
{profile.name}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
{selectedVoices.length > 0 && (
|
|
||||||
<div className="mt-2 space-y-1">
|
|
||||||
{selectedVoices.map((profileId) => {
|
|
||||||
const profile = profiles.find((p) => p.id === profileId);
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={profileId}
|
|
||||||
className="flex items-center justify-between text-sm bg-muted p-2 rounded"
|
|
||||||
>
|
|
||||||
<span>{profile?.name || profileId}</span>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
onClick={() =>
|
|
||||||
setSelectedVoices(selectedVoices.filter((id) => id !== profileId))
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Trash2 className="h-3 w-3" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<DialogFooter>
|
|
||||||
<Button variant="outline" onClick={() => onOpenChange(false)}>
|
|
||||||
{t('common.cancel')}
|
|
||||||
</Button>
|
|
||||||
<Button onClick={handleSubmit} disabled={!name.trim()}>
|
|
||||||
{t('common.save')}
|
|
||||||
</Button>
|
|
||||||
</DialogFooter>
|
|
||||||
</DialogContent>
|
|
||||||
</Dialog>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
||||||
import type { ApiResult } from './ApiResult';
|
|
||||||
|
|
||||||
export class ApiError extends Error {
|
|
||||||
public readonly url: string;
|
|
||||||
public readonly status: number;
|
|
||||||
public readonly statusText: string;
|
|
||||||
public readonly body: any;
|
|
||||||
public readonly request: ApiRequestOptions;
|
|
||||||
|
|
||||||
constructor(request: ApiRequestOptions, response: ApiResult, message: string) {
|
|
||||||
super(message);
|
|
||||||
|
|
||||||
this.name = 'ApiError';
|
|
||||||
this.url = response.url;
|
|
||||||
this.status = response.status;
|
|
||||||
this.statusText = response.statusText;
|
|
||||||
this.body = response.body;
|
|
||||||
this.request = request;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export type ApiRequestOptions = {
|
|
||||||
readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
|
|
||||||
readonly url: string;
|
|
||||||
readonly path?: Record<string, any>;
|
|
||||||
readonly cookies?: Record<string, any>;
|
|
||||||
readonly headers?: Record<string, any>;
|
|
||||||
readonly query?: Record<string, any>;
|
|
||||||
readonly formData?: Record<string, any>;
|
|
||||||
readonly body?: any;
|
|
||||||
readonly mediaType?: string;
|
|
||||||
readonly responseHeader?: string;
|
|
||||||
readonly errors?: Record<number, string>;
|
|
||||||
};
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export type ApiResult = {
|
|
||||||
readonly url: string;
|
|
||||||
readonly ok: boolean;
|
|
||||||
readonly status: number;
|
|
||||||
readonly statusText: string;
|
|
||||||
readonly body: any;
|
|
||||||
};
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export class CancelError extends Error {
|
|
||||||
constructor(message: string) {
|
|
||||||
super(message);
|
|
||||||
this.name = 'CancelError';
|
|
||||||
}
|
|
||||||
|
|
||||||
public get isCancelled(): boolean {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface OnCancel {
|
|
||||||
readonly isResolved: boolean;
|
|
||||||
readonly isRejected: boolean;
|
|
||||||
readonly isCancelled: boolean;
|
|
||||||
|
|
||||||
(cancelHandler: () => void): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class CancelablePromise<T> implements Promise<T> {
|
|
||||||
#isResolved: boolean;
|
|
||||||
#isRejected: boolean;
|
|
||||||
#isCancelled: boolean;
|
|
||||||
readonly #cancelHandlers: (() => void)[];
|
|
||||||
readonly #promise: Promise<T>;
|
|
||||||
#resolve?: (value: T | PromiseLike<T>) => void;
|
|
||||||
#reject?: (reason?: any) => void;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
executor: (
|
|
||||||
resolve: (value: T | PromiseLike<T>) => void,
|
|
||||||
reject: (reason?: any) => void,
|
|
||||||
onCancel: OnCancel,
|
|
||||||
) => void,
|
|
||||||
) {
|
|
||||||
this.#isResolved = false;
|
|
||||||
this.#isRejected = false;
|
|
||||||
this.#isCancelled = false;
|
|
||||||
this.#cancelHandlers = [];
|
|
||||||
this.#promise = new Promise<T>((resolve, reject) => {
|
|
||||||
this.#resolve = resolve;
|
|
||||||
this.#reject = reject;
|
|
||||||
|
|
||||||
const onResolve = (value: T | PromiseLike<T>): void => {
|
|
||||||
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.#isResolved = true;
|
|
||||||
if (this.#resolve) this.#resolve(value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onReject = (reason?: any): void => {
|
|
||||||
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.#isRejected = true;
|
|
||||||
if (this.#reject) this.#reject(reason);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onCancel = (cancelHandler: () => void): void => {
|
|
||||||
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.#cancelHandlers.push(cancelHandler);
|
|
||||||
};
|
|
||||||
|
|
||||||
Object.defineProperty(onCancel, 'isResolved', {
|
|
||||||
get: (): boolean => this.#isResolved,
|
|
||||||
});
|
|
||||||
|
|
||||||
Object.defineProperty(onCancel, 'isRejected', {
|
|
||||||
get: (): boolean => this.#isRejected,
|
|
||||||
});
|
|
||||||
|
|
||||||
Object.defineProperty(onCancel, 'isCancelled', {
|
|
||||||
get: (): boolean => this.#isCancelled,
|
|
||||||
});
|
|
||||||
|
|
||||||
return executor(onResolve, onReject, onCancel as OnCancel);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
get [Symbol.toStringTag]() {
|
|
||||||
return 'Cancellable Promise';
|
|
||||||
}
|
|
||||||
|
|
||||||
public then<TResult1 = T, TResult2 = never>(
|
|
||||||
onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,
|
|
||||||
onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null,
|
|
||||||
): Promise<TResult1 | TResult2> {
|
|
||||||
return this.#promise.then(onFulfilled, onRejected);
|
|
||||||
}
|
|
||||||
|
|
||||||
public catch<TResult = never>(
|
|
||||||
onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null,
|
|
||||||
): Promise<T | TResult> {
|
|
||||||
return this.#promise.catch(onRejected);
|
|
||||||
}
|
|
||||||
|
|
||||||
public finally(onFinally?: (() => void) | null): Promise<T> {
|
|
||||||
return this.#promise.finally(onFinally);
|
|
||||||
}
|
|
||||||
|
|
||||||
public cancel(): void {
|
|
||||||
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.#isCancelled = true;
|
|
||||||
if (this.#cancelHandlers.length) {
|
|
||||||
try {
|
|
||||||
for (const cancelHandler of this.#cancelHandlers) {
|
|
||||||
cancelHandler();
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.warn('Cancellation threw an error', error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.#cancelHandlers.length = 0;
|
|
||||||
if (this.#reject) this.#reject(new CancelError('Request aborted'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public get isCancelled(): boolean {
|
|
||||||
return this.#isCancelled;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
||||||
|
|
||||||
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
|
|
||||||
type Headers = Record<string, string>;
|
|
||||||
|
|
||||||
export type OpenAPIConfig = {
|
|
||||||
BASE: string;
|
|
||||||
VERSION: string;
|
|
||||||
WITH_CREDENTIALS: boolean;
|
|
||||||
CREDENTIALS: 'include' | 'omit' | 'same-origin';
|
|
||||||
TOKEN?: string | Resolver<string> | undefined;
|
|
||||||
USERNAME?: string | Resolver<string> | undefined;
|
|
||||||
PASSWORD?: string | Resolver<string> | undefined;
|
|
||||||
HEADERS?: Headers | Resolver<Headers> | undefined;
|
|
||||||
ENCODE_PATH?: ((path: string) => string) | undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const OpenAPI: OpenAPIConfig = {
|
|
||||||
BASE: '',
|
|
||||||
VERSION: '0.1.0',
|
|
||||||
WITH_CREDENTIALS: false,
|
|
||||||
CREDENTIALS: 'include',
|
|
||||||
TOKEN: undefined,
|
|
||||||
USERNAME: undefined,
|
|
||||||
PASSWORD: undefined,
|
|
||||||
HEADERS: undefined,
|
|
||||||
ENCODE_PATH: undefined,
|
|
||||||
};
|
|
||||||
@@ -1,341 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
import { ApiError } from './ApiError';
|
|
||||||
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
||||||
import type { ApiResult } from './ApiResult';
|
|
||||||
import { CancelablePromise } from './CancelablePromise';
|
|
||||||
import type { OnCancel } from './CancelablePromise';
|
|
||||||
import type { OpenAPIConfig } from './OpenAPI';
|
|
||||||
|
|
||||||
export const isDefined = <T>(
|
|
||||||
value: T | null | undefined,
|
|
||||||
): value is Exclude<T, null | undefined> => {
|
|
||||||
return value !== undefined && value !== null;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const isString = (value: any): value is string => {
|
|
||||||
return typeof value === 'string';
|
|
||||||
};
|
|
||||||
|
|
||||||
export const isStringWithValue = (value: any): value is string => {
|
|
||||||
return isString(value) && value !== '';
|
|
||||||
};
|
|
||||||
|
|
||||||
export const isBlob = (value: any): value is Blob => {
|
|
||||||
return (
|
|
||||||
typeof value === 'object' &&
|
|
||||||
typeof value.type === 'string' &&
|
|
||||||
typeof value.stream === 'function' &&
|
|
||||||
typeof value.arrayBuffer === 'function' &&
|
|
||||||
typeof value.constructor === 'function' &&
|
|
||||||
typeof value.constructor.name === 'string' &&
|
|
||||||
/^(Blob|File)$/.test(value.constructor.name) &&
|
|
||||||
/^(Blob|File)$/.test(value[Symbol.toStringTag])
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const isFormData = (value: any): value is FormData => {
|
|
||||||
return value instanceof FormData;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const base64 = (str: string): string => {
|
|
||||||
try {
|
|
||||||
return btoa(str);
|
|
||||||
} catch (err) {
|
|
||||||
// @ts-ignore
|
|
||||||
return Buffer.from(str).toString('base64');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getQueryString = (params: Record<string, any>): string => {
|
|
||||||
const qs: string[] = [];
|
|
||||||
|
|
||||||
const append = (key: string, value: any) => {
|
|
||||||
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
||||||
};
|
|
||||||
|
|
||||||
const process = (key: string, value: any) => {
|
|
||||||
if (isDefined(value)) {
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
value.forEach((v) => {
|
|
||||||
process(key, v);
|
|
||||||
});
|
|
||||||
} else if (typeof value === 'object') {
|
|
||||||
Object.entries(value).forEach(([k, v]) => {
|
|
||||||
process(`${key}[${k}]`, v);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
append(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Object.entries(params).forEach(([key, value]) => {
|
|
||||||
process(key, value);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (qs.length > 0) {
|
|
||||||
return `?${qs.join('&')}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
|
||||||
};
|
|
||||||
|
|
||||||
const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => {
|
|
||||||
const encoder = config.ENCODE_PATH || encodeURI;
|
|
||||||
|
|
||||||
const path = options.url
|
|
||||||
.replace('{api-version}', config.VERSION)
|
|
||||||
.replace(/{(.*?)}/g, (substring: string, group: string) => {
|
|
||||||
if (options.path?.hasOwnProperty(group)) {
|
|
||||||
return encoder(String(options.path[group]));
|
|
||||||
}
|
|
||||||
return substring;
|
|
||||||
});
|
|
||||||
|
|
||||||
const url = `${config.BASE}${path}`;
|
|
||||||
if (options.query) {
|
|
||||||
return `${url}${getQueryString(options.query)}`;
|
|
||||||
}
|
|
||||||
return url;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getFormData = (options: ApiRequestOptions): FormData | undefined => {
|
|
||||||
if (options.formData) {
|
|
||||||
const formData = new FormData();
|
|
||||||
|
|
||||||
const process = (key: string, value: any) => {
|
|
||||||
if (isString(value) || isBlob(value)) {
|
|
||||||
formData.append(key, value);
|
|
||||||
} else {
|
|
||||||
formData.append(key, JSON.stringify(value));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Object.entries(options.formData)
|
|
||||||
.filter(([_, value]) => isDefined(value))
|
|
||||||
.forEach(([key, value]) => {
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
value.forEach((v) => process(key, v));
|
|
||||||
} else {
|
|
||||||
process(key, value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return formData;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
|
|
||||||
|
|
||||||
export const resolve = async <T>(
|
|
||||||
options: ApiRequestOptions,
|
|
||||||
resolver?: T | Resolver<T>,
|
|
||||||
): Promise<T | undefined> => {
|
|
||||||
if (typeof resolver === 'function') {
|
|
||||||
return (resolver as Resolver<T>)(options);
|
|
||||||
}
|
|
||||||
return resolver;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getHeaders = async (
|
|
||||||
config: OpenAPIConfig,
|
|
||||||
options: ApiRequestOptions,
|
|
||||||
): Promise<Headers> => {
|
|
||||||
const [token, username, password, additionalHeaders] = await Promise.all([
|
|
||||||
resolve(options, config.TOKEN),
|
|
||||||
resolve(options, config.USERNAME),
|
|
||||||
resolve(options, config.PASSWORD),
|
|
||||||
resolve(options, config.HEADERS),
|
|
||||||
]);
|
|
||||||
|
|
||||||
const headers = Object.entries({
|
|
||||||
Accept: 'application/json',
|
|
||||||
...additionalHeaders,
|
|
||||||
...options.headers,
|
|
||||||
})
|
|
||||||
.filter(([_, value]) => isDefined(value))
|
|
||||||
.reduce(
|
|
||||||
(headers, [key, value]) => ({
|
|
||||||
...headers,
|
|
||||||
[key]: String(value),
|
|
||||||
}),
|
|
||||||
{} as Record<string, string>,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isStringWithValue(token)) {
|
|
||||||
headers['Authorization'] = `Bearer ${token}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isStringWithValue(username) && isStringWithValue(password)) {
|
|
||||||
const credentials = base64(`${username}:${password}`);
|
|
||||||
headers['Authorization'] = `Basic ${credentials}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.body !== undefined) {
|
|
||||||
if (options.mediaType) {
|
|
||||||
headers['Content-Type'] = options.mediaType;
|
|
||||||
} else if (isBlob(options.body)) {
|
|
||||||
headers['Content-Type'] = options.body.type || 'application/octet-stream';
|
|
||||||
} else if (isString(options.body)) {
|
|
||||||
headers['Content-Type'] = 'text/plain';
|
|
||||||
} else if (!isFormData(options.body)) {
|
|
||||||
headers['Content-Type'] = 'application/json';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Headers(headers);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getRequestBody = (options: ApiRequestOptions): any => {
|
|
||||||
if (options.body !== undefined) {
|
|
||||||
if (options.mediaType?.includes('/json')) {
|
|
||||||
return JSON.stringify(options.body);
|
|
||||||
} else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
|
|
||||||
return options.body;
|
|
||||||
} else {
|
|
||||||
return JSON.stringify(options.body);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const sendRequest = async (
|
|
||||||
config: OpenAPIConfig,
|
|
||||||
options: ApiRequestOptions,
|
|
||||||
url: string,
|
|
||||||
body: any,
|
|
||||||
formData: FormData | undefined,
|
|
||||||
headers: Headers,
|
|
||||||
onCancel: OnCancel,
|
|
||||||
): Promise<Response> => {
|
|
||||||
const controller = new AbortController();
|
|
||||||
|
|
||||||
const request: RequestInit = {
|
|
||||||
headers,
|
|
||||||
body: body ?? formData,
|
|
||||||
method: options.method,
|
|
||||||
signal: controller.signal,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (config.WITH_CREDENTIALS) {
|
|
||||||
request.credentials = config.CREDENTIALS;
|
|
||||||
}
|
|
||||||
|
|
||||||
onCancel(() => controller.abort());
|
|
||||||
|
|
||||||
return await fetch(url, request);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getResponseHeader = (
|
|
||||||
response: Response,
|
|
||||||
responseHeader?: string,
|
|
||||||
): string | undefined => {
|
|
||||||
if (responseHeader) {
|
|
||||||
const content = response.headers.get(responseHeader);
|
|
||||||
if (isString(content)) {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getResponseBody = async (response: Response): Promise<any> => {
|
|
||||||
if (response.status !== 204) {
|
|
||||||
try {
|
|
||||||
const contentType = response.headers.get('Content-Type');
|
|
||||||
if (contentType) {
|
|
||||||
const jsonTypes = ['application/json', 'application/problem+json'];
|
|
||||||
const isJSON = jsonTypes.some((type) => contentType.toLowerCase().startsWith(type));
|
|
||||||
if (isJSON) {
|
|
||||||
return await response.json();
|
|
||||||
} else {
|
|
||||||
return await response.text();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): void => {
|
|
||||||
const errors: Record<number, string> = {
|
|
||||||
400: 'Bad Request',
|
|
||||||
401: 'Unauthorized',
|
|
||||||
403: 'Forbidden',
|
|
||||||
404: 'Not Found',
|
|
||||||
500: 'Internal Server Error',
|
|
||||||
502: 'Bad Gateway',
|
|
||||||
503: 'Service Unavailable',
|
|
||||||
...options.errors,
|
|
||||||
};
|
|
||||||
|
|
||||||
const error = errors[result.status];
|
|
||||||
if (error) {
|
|
||||||
throw new ApiError(options, result, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!result.ok) {
|
|
||||||
const errorStatus = result.status ?? 'unknown';
|
|
||||||
const errorStatusText = result.statusText ?? 'unknown';
|
|
||||||
const errorBody = (() => {
|
|
||||||
try {
|
|
||||||
return JSON.stringify(result.body, null, 2);
|
|
||||||
} catch (e) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
throw new ApiError(
|
|
||||||
options,
|
|
||||||
result,
|
|
||||||
`Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request method
|
|
||||||
* @param config The OpenAPI configuration object
|
|
||||||
* @param options The request options from the service
|
|
||||||
* @returns CancelablePromise<T>
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
export const request = <T>(
|
|
||||||
config: OpenAPIConfig,
|
|
||||||
options: ApiRequestOptions,
|
|
||||||
): CancelablePromise<T> => {
|
|
||||||
return new CancelablePromise(async (resolve, reject, onCancel) => {
|
|
||||||
try {
|
|
||||||
const url = getUrl(config, options);
|
|
||||||
const formData = getFormData(options);
|
|
||||||
const body = getRequestBody(options);
|
|
||||||
const headers = await getHeaders(config, options);
|
|
||||||
|
|
||||||
if (!onCancel.isCancelled) {
|
|
||||||
const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
|
|
||||||
const responseBody = await getResponseBody(response);
|
|
||||||
const responseHeader = getResponseHeader(response, options.responseHeader);
|
|
||||||
|
|
||||||
const result: ApiResult = {
|
|
||||||
url,
|
|
||||||
ok: response.ok,
|
|
||||||
status: response.status,
|
|
||||||
statusText: response.statusText,
|
|
||||||
body: responseHeader ?? responseBody,
|
|
||||||
};
|
|
||||||
|
|
||||||
catchErrorCodes(options, result);
|
|
||||||
|
|
||||||
resolve(result.body);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
reject(error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export { ApiError } from './core/ApiError';
|
|
||||||
export { CancelablePromise, CancelError } from './core/CancelablePromise';
|
|
||||||
export { OpenAPI } from './core/OpenAPI';
|
|
||||||
export type { OpenAPIConfig } from './core/OpenAPI';
|
|
||||||
|
|
||||||
export type { Body_add_profile_sample_profiles__profile_id__samples_post } from './models/Body_add_profile_sample_profiles__profile_id__samples_post';
|
|
||||||
export type { Body_transcribe_audio_transcribe_post } from './models/Body_transcribe_audio_transcribe_post';
|
|
||||||
export type { GenerationRequest } from './models/GenerationRequest';
|
|
||||||
export type { GenerationResponse } from './models/GenerationResponse';
|
|
||||||
export type { HealthResponse } from './models/HealthResponse';
|
|
||||||
export type { HistoryListResponse } from './models/HistoryListResponse';
|
|
||||||
export type { HistoryResponse } from './models/HistoryResponse';
|
|
||||||
export type { HTTPValidationError } from './models/HTTPValidationError';
|
|
||||||
export type { ModelDownloadRequest } from './models/ModelDownloadRequest';
|
|
||||||
export type { ModelStatus } from './models/ModelStatus';
|
|
||||||
export type { ModelStatusListResponse } from './models/ModelStatusListResponse';
|
|
||||||
export type { ProfileSampleResponse } from './models/ProfileSampleResponse';
|
|
||||||
export type { TranscriptionResponse } from './models/TranscriptionResponse';
|
|
||||||
export type { ValidationError } from './models/ValidationError';
|
|
||||||
export type { VoiceProfileCreate } from './models/VoiceProfileCreate';
|
|
||||||
export type { VoiceProfileResponse } from './models/VoiceProfileResponse';
|
|
||||||
|
|
||||||
export { $Body_add_profile_sample_profiles__profile_id__samples_post } from './schemas/$Body_add_profile_sample_profiles__profile_id__samples_post';
|
|
||||||
export { $Body_transcribe_audio_transcribe_post } from './schemas/$Body_transcribe_audio_transcribe_post';
|
|
||||||
export { $GenerationRequest } from './schemas/$GenerationRequest';
|
|
||||||
export { $GenerationResponse } from './schemas/$GenerationResponse';
|
|
||||||
export { $HealthResponse } from './schemas/$HealthResponse';
|
|
||||||
export { $HistoryListResponse } from './schemas/$HistoryListResponse';
|
|
||||||
export { $HistoryResponse } from './schemas/$HistoryResponse';
|
|
||||||
export { $HTTPValidationError } from './schemas/$HTTPValidationError';
|
|
||||||
export { $ModelDownloadRequest } from './schemas/$ModelDownloadRequest';
|
|
||||||
export { $ModelStatus } from './schemas/$ModelStatus';
|
|
||||||
export { $ModelStatusListResponse } from './schemas/$ModelStatusListResponse';
|
|
||||||
export { $ProfileSampleResponse } from './schemas/$ProfileSampleResponse';
|
|
||||||
export { $TranscriptionResponse } from './schemas/$TranscriptionResponse';
|
|
||||||
export { $ValidationError } from './schemas/$ValidationError';
|
|
||||||
export { $VoiceProfileCreate } from './schemas/$VoiceProfileCreate';
|
|
||||||
export { $VoiceProfileResponse } from './schemas/$VoiceProfileResponse';
|
|
||||||
|
|
||||||
export { DefaultService } from './services/DefaultService';
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export type Body_add_profile_sample_profiles__profile_id__samples_post = {
|
|
||||||
file: Blob;
|
|
||||||
reference_text: string;
|
|
||||||
};
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export type Body_transcribe_audio_transcribe_post = {
|
|
||||||
file: Blob;
|
|
||||||
language?: string | null;
|
|
||||||
};
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
/**
|
|
||||||
* Request model for voice generation.
|
|
||||||
*/
|
|
||||||
export type GenerationRequest = {
|
|
||||||
profile_id: string;
|
|
||||||
text: string;
|
|
||||||
language?: string;
|
|
||||||
seed?: number | null;
|
|
||||||
model_size?: string | null;
|
|
||||||
instruct?: string | null;
|
|
||||||
};
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
/**
|
|
||||||
* Response model for voice generation.
|
|
||||||
*/
|
|
||||||
export type GenerationResponse = {
|
|
||||||
id: string;
|
|
||||||
profile_id: string;
|
|
||||||
text: string;
|
|
||||||
language: string;
|
|
||||||
audio_path: string;
|
|
||||||
duration: number;
|
|
||||||
seed: number | null;
|
|
||||||
instruct: string | null;
|
|
||||||
created_at: string;
|
|
||||||
};
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
import type { ValidationError } from './ValidationError';
|
|
||||||
export type HTTPValidationError = {
|
|
||||||
detail?: Array<ValidationError>;
|
|
||||||
};
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
/**
|
|
||||||
* Response model for health check.
|
|
||||||
*/
|
|
||||||
export type HealthResponse = {
|
|
||||||
status: string;
|
|
||||||
model_loaded: boolean;
|
|
||||||
model_downloaded?: boolean | null;
|
|
||||||
model_size?: string | null;
|
|
||||||
gpu_available: boolean;
|
|
||||||
vram_used_mb?: number | null;
|
|
||||||
};
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
import type { HistoryResponse } from './HistoryResponse';
|
|
||||||
/**
|
|
||||||
* Response model for history list.
|
|
||||||
*/
|
|
||||||
export type HistoryListResponse = {
|
|
||||||
items: Array<HistoryResponse>;
|
|
||||||
total: number;
|
|
||||||
};
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
/**
|
|
||||||
* Response model for history entry (includes profile name).
|
|
||||||
*/
|
|
||||||
export type HistoryResponse = {
|
|
||||||
id: string;
|
|
||||||
profile_id: string;
|
|
||||||
profile_name: string;
|
|
||||||
text: string;
|
|
||||||
language: string;
|
|
||||||
audio_path: string;
|
|
||||||
duration: number;
|
|
||||||
seed: number | null;
|
|
||||||
instruct: string | null;
|
|
||||||
created_at: string;
|
|
||||||
};
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
/**
|
|
||||||
* Request model for triggering model download.
|
|
||||||
*/
|
|
||||||
export type ModelDownloadRequest = {
|
|
||||||
model_name: string;
|
|
||||||
};
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
/**
|
|
||||||
* Response model for model status.
|
|
||||||
*/
|
|
||||||
export type ModelStatus = {
|
|
||||||
model_name: string;
|
|
||||||
display_name: string;
|
|
||||||
downloaded: boolean;
|
|
||||||
downloading?: boolean; // True if download is in progress
|
|
||||||
size_mb?: number | null;
|
|
||||||
loaded?: boolean;
|
|
||||||
};
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
import type { ModelStatus } from './ModelStatus';
|
|
||||||
/**
|
|
||||||
* Response model for model status list.
|
|
||||||
*/
|
|
||||||
export type ModelStatusListResponse = {
|
|
||||||
models: Array<ModelStatus>;
|
|
||||||
};
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
/**
|
|
||||||
* Response model for profile sample.
|
|
||||||
*/
|
|
||||||
export type ProfileSampleResponse = {
|
|
||||||
id: string;
|
|
||||||
profile_id: string;
|
|
||||||
audio_path: string;
|
|
||||||
reference_text: string;
|
|
||||||
};
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
/**
|
|
||||||
* Response model for transcription.
|
|
||||||
*/
|
|
||||||
export type TranscriptionResponse = {
|
|
||||||
text: string;
|
|
||||||
duration: number;
|
|
||||||
};
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export type ValidationError = {
|
|
||||||
loc: Array<string | number>;
|
|
||||||
msg: string;
|
|
||||||
type: string;
|
|
||||||
};
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
/**
|
|
||||||
* Request model for creating a voice profile.
|
|
||||||
*/
|
|
||||||
export type VoiceProfileCreate = {
|
|
||||||
name: string;
|
|
||||||
description?: string | null;
|
|
||||||
language?: string;
|
|
||||||
};
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
/**
|
|
||||||
* Response model for voice profile.
|
|
||||||
*/
|
|
||||||
export type VoiceProfileResponse = {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
description: string | null;
|
|
||||||
language: string;
|
|
||||||
created_at: string;
|
|
||||||
updated_at: string;
|
|
||||||
};
|
|
||||||
-17
@@ -1,17 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export const $Body_add_profile_sample_profiles__profile_id__samples_post = {
|
|
||||||
properties: {
|
|
||||||
file: {
|
|
||||||
type: 'binary',
|
|
||||||
isRequired: true,
|
|
||||||
format: 'binary',
|
|
||||||
},
|
|
||||||
reference_text: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export const $Body_transcribe_audio_transcribe_post = {
|
|
||||||
properties: {
|
|
||||||
file: {
|
|
||||||
type: 'binary',
|
|
||||||
isRequired: true,
|
|
||||||
format: 'binary',
|
|
||||||
},
|
|
||||||
language: {
|
|
||||||
type: 'any-of',
|
|
||||||
contains: [
|
|
||||||
{
|
|
||||||
type: 'string',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'null',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export const $GenerationRequest = {
|
|
||||||
description: `Request model for voice generation.`,
|
|
||||||
properties: {
|
|
||||||
profile_id: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
text: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
maxLength: 5000,
|
|
||||||
minLength: 1,
|
|
||||||
},
|
|
||||||
language: {
|
|
||||||
type: 'string',
|
|
||||||
pattern: '^(en|zh)$',
|
|
||||||
},
|
|
||||||
seed: {
|
|
||||||
type: 'any-of',
|
|
||||||
contains: [
|
|
||||||
{
|
|
||||||
type: 'number',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'null',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
model_size: {
|
|
||||||
type: 'any-of',
|
|
||||||
contains: [
|
|
||||||
{
|
|
||||||
type: 'string',
|
|
||||||
pattern: '^(1\\.7B|0\\.6B)$',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'null',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export const $GenerationResponse = {
|
|
||||||
description: `Response model for voice generation.`,
|
|
||||||
properties: {
|
|
||||||
id: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
profile_id: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
text: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
language: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
audio_path: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
duration: {
|
|
||||||
type: 'number',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
seed: {
|
|
||||||
type: 'any-of',
|
|
||||||
contains: [
|
|
||||||
{
|
|
||||||
type: 'number',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'null',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
created_at: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
format: 'date-time',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export const $HTTPValidationError = {
|
|
||||||
properties: {
|
|
||||||
detail: {
|
|
||||||
type: 'array',
|
|
||||||
contains: {
|
|
||||||
type: 'ValidationError',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export const $HealthResponse = {
|
|
||||||
description: `Response model for health check.`,
|
|
||||||
properties: {
|
|
||||||
status: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
model_loaded: {
|
|
||||||
type: 'boolean',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
model_downloaded: {
|
|
||||||
type: 'any-of',
|
|
||||||
contains: [
|
|
||||||
{
|
|
||||||
type: 'boolean',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'null',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
model_size: {
|
|
||||||
type: 'any-of',
|
|
||||||
contains: [
|
|
||||||
{
|
|
||||||
type: 'string',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'null',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
gpu_available: {
|
|
||||||
type: 'boolean',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
vram_used_mb: {
|
|
||||||
type: 'any-of',
|
|
||||||
contains: [
|
|
||||||
{
|
|
||||||
type: 'number',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'null',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export const $HistoryListResponse = {
|
|
||||||
description: `Response model for history list.`,
|
|
||||||
properties: {
|
|
||||||
items: {
|
|
||||||
type: 'array',
|
|
||||||
contains: {
|
|
||||||
type: 'HistoryResponse',
|
|
||||||
},
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
total: {
|
|
||||||
type: 'number',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export const $HistoryResponse = {
|
|
||||||
description: `Response model for history entry (includes profile name).`,
|
|
||||||
properties: {
|
|
||||||
id: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
profile_id: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
profile_name: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
text: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
language: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
audio_path: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
duration: {
|
|
||||||
type: 'number',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
seed: {
|
|
||||||
type: 'any-of',
|
|
||||||
contains: [
|
|
||||||
{
|
|
||||||
type: 'number',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'null',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
created_at: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
format: 'date-time',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export const $ModelDownloadRequest = {
|
|
||||||
description: `Request model for triggering model download.`,
|
|
||||||
properties: {
|
|
||||||
model_name: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export const $ModelStatus = {
|
|
||||||
description: `Response model for model status.`,
|
|
||||||
properties: {
|
|
||||||
model_name: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
display_name: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
downloaded: {
|
|
||||||
type: 'boolean',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
size_mb: {
|
|
||||||
type: 'any-of',
|
|
||||||
contains: [
|
|
||||||
{
|
|
||||||
type: 'number',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'null',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
loaded: {
|
|
||||||
type: 'boolean',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export const $ModelStatusListResponse = {
|
|
||||||
description: `Response model for model status list.`,
|
|
||||||
properties: {
|
|
||||||
models: {
|
|
||||||
type: 'array',
|
|
||||||
contains: {
|
|
||||||
type: 'ModelStatus',
|
|
||||||
},
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export const $ProfileSampleResponse = {
|
|
||||||
description: `Response model for profile sample.`,
|
|
||||||
properties: {
|
|
||||||
id: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
profile_id: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
audio_path: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
reference_text: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export const $TranscriptionResponse = {
|
|
||||||
description: `Response model for transcription.`,
|
|
||||||
properties: {
|
|
||||||
text: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
duration: {
|
|
||||||
type: 'number',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export const $ValidationError = {
|
|
||||||
properties: {
|
|
||||||
loc: {
|
|
||||||
type: 'array',
|
|
||||||
contains: {
|
|
||||||
type: 'any-of',
|
|
||||||
contains: [
|
|
||||||
{
|
|
||||||
type: 'string',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'number',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
msg: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
type: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export const $VoiceProfileCreate = {
|
|
||||||
description: `Request model for creating a voice profile.`,
|
|
||||||
properties: {
|
|
||||||
name: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
maxLength: 100,
|
|
||||||
minLength: 1,
|
|
||||||
},
|
|
||||||
description: {
|
|
||||||
type: 'any-of',
|
|
||||||
contains: [
|
|
||||||
{
|
|
||||||
type: 'string',
|
|
||||||
maxLength: 500,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'null',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
language: {
|
|
||||||
type: 'string',
|
|
||||||
pattern: '^(en|zh)$',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
export const $VoiceProfileResponse = {
|
|
||||||
description: `Response model for voice profile.`,
|
|
||||||
properties: {
|
|
||||||
id: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
name: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
description: {
|
|
||||||
type: 'any-of',
|
|
||||||
contains: [
|
|
||||||
{
|
|
||||||
type: 'string',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'null',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
language: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
},
|
|
||||||
created_at: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
format: 'date-time',
|
|
||||||
},
|
|
||||||
updated_at: {
|
|
||||||
type: 'string',
|
|
||||||
isRequired: true,
|
|
||||||
format: 'date-time',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
@@ -1,459 +0,0 @@
|
|||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
import type { Body_add_profile_sample_profiles__profile_id__samples_post } from '../models/Body_add_profile_sample_profiles__profile_id__samples_post';
|
|
||||||
import type { Body_transcribe_audio_transcribe_post } from '../models/Body_transcribe_audio_transcribe_post';
|
|
||||||
import type { GenerationRequest } from '../models/GenerationRequest';
|
|
||||||
import type { GenerationResponse } from '../models/GenerationResponse';
|
|
||||||
import type { HealthResponse } from '../models/HealthResponse';
|
|
||||||
import type { HistoryListResponse } from '../models/HistoryListResponse';
|
|
||||||
import type { HistoryResponse } from '../models/HistoryResponse';
|
|
||||||
import type { ModelDownloadRequest } from '../models/ModelDownloadRequest';
|
|
||||||
import type { ModelStatusListResponse } from '../models/ModelStatusListResponse';
|
|
||||||
import type { ProfileSampleResponse } from '../models/ProfileSampleResponse';
|
|
||||||
import type { TranscriptionResponse } from '../models/TranscriptionResponse';
|
|
||||||
import type { VoiceProfileCreate } from '../models/VoiceProfileCreate';
|
|
||||||
import type { VoiceProfileResponse } from '../models/VoiceProfileResponse';
|
|
||||||
import type { CancelablePromise } from '../core/CancelablePromise';
|
|
||||||
import { OpenAPI } from '../core/OpenAPI';
|
|
||||||
import { request as __request } from '../core/request';
|
|
||||||
export class DefaultService {
|
|
||||||
/**
|
|
||||||
* Root
|
|
||||||
* Root endpoint.
|
|
||||||
* @returns any Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static rootGet(): CancelablePromise<any> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'GET',
|
|
||||||
url: '/',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Health
|
|
||||||
* Health check endpoint.
|
|
||||||
* @returns HealthResponse Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static healthHealthGet(): CancelablePromise<HealthResponse> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'GET',
|
|
||||||
url: '/health',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* List Profiles
|
|
||||||
* List all voice profiles.
|
|
||||||
* @returns VoiceProfileResponse Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static listProfilesProfilesGet(): CancelablePromise<Array<VoiceProfileResponse>> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'GET',
|
|
||||||
url: '/profiles',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Create Profile
|
|
||||||
* Create a new voice profile.
|
|
||||||
* @returns VoiceProfileResponse Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static createProfileProfilesPost({
|
|
||||||
requestBody,
|
|
||||||
}: {
|
|
||||||
requestBody: VoiceProfileCreate;
|
|
||||||
}): CancelablePromise<VoiceProfileResponse> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'POST',
|
|
||||||
url: '/profiles',
|
|
||||||
body: requestBody,
|
|
||||||
mediaType: 'application/json',
|
|
||||||
errors: {
|
|
||||||
422: `Validation Error`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get Profile
|
|
||||||
* Get a voice profile by ID.
|
|
||||||
* @returns VoiceProfileResponse Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static getProfileProfilesProfileIdGet({
|
|
||||||
profileId,
|
|
||||||
}: {
|
|
||||||
profileId: string;
|
|
||||||
}): CancelablePromise<VoiceProfileResponse> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'GET',
|
|
||||||
url: '/profiles/{profile_id}',
|
|
||||||
path: {
|
|
||||||
profile_id: profileId,
|
|
||||||
},
|
|
||||||
errors: {
|
|
||||||
422: `Validation Error`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Update Profile
|
|
||||||
* Update a voice profile.
|
|
||||||
* @returns VoiceProfileResponse Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static updateProfileProfilesProfileIdPut({
|
|
||||||
profileId,
|
|
||||||
requestBody,
|
|
||||||
}: {
|
|
||||||
profileId: string;
|
|
||||||
requestBody: VoiceProfileCreate;
|
|
||||||
}): CancelablePromise<VoiceProfileResponse> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'PUT',
|
|
||||||
url: '/profiles/{profile_id}',
|
|
||||||
path: {
|
|
||||||
profile_id: profileId,
|
|
||||||
},
|
|
||||||
body: requestBody,
|
|
||||||
mediaType: 'application/json',
|
|
||||||
errors: {
|
|
||||||
422: `Validation Error`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Delete Profile
|
|
||||||
* Delete a voice profile.
|
|
||||||
* @returns any Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static deleteProfileProfilesProfileIdDelete({
|
|
||||||
profileId,
|
|
||||||
}: {
|
|
||||||
profileId: string;
|
|
||||||
}): CancelablePromise<any> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'DELETE',
|
|
||||||
url: '/profiles/{profile_id}',
|
|
||||||
path: {
|
|
||||||
profile_id: profileId,
|
|
||||||
},
|
|
||||||
errors: {
|
|
||||||
422: `Validation Error`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Add Profile Sample
|
|
||||||
* Add a sample to a voice profile.
|
|
||||||
* @returns ProfileSampleResponse Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static addProfileSampleProfilesProfileIdSamplesPost({
|
|
||||||
profileId,
|
|
||||||
formData,
|
|
||||||
}: {
|
|
||||||
profileId: string;
|
|
||||||
formData: Body_add_profile_sample_profiles__profile_id__samples_post;
|
|
||||||
}): CancelablePromise<ProfileSampleResponse> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'POST',
|
|
||||||
url: '/profiles/{profile_id}/samples',
|
|
||||||
path: {
|
|
||||||
profile_id: profileId,
|
|
||||||
},
|
|
||||||
formData: formData,
|
|
||||||
mediaType: 'multipart/form-data',
|
|
||||||
errors: {
|
|
||||||
422: `Validation Error`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get Profile Samples
|
|
||||||
* Get all samples for a profile.
|
|
||||||
* @returns ProfileSampleResponse Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static getProfileSamplesProfilesProfileIdSamplesGet({
|
|
||||||
profileId,
|
|
||||||
}: {
|
|
||||||
profileId: string;
|
|
||||||
}): CancelablePromise<Array<ProfileSampleResponse>> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'GET',
|
|
||||||
url: '/profiles/{profile_id}/samples',
|
|
||||||
path: {
|
|
||||||
profile_id: profileId,
|
|
||||||
},
|
|
||||||
errors: {
|
|
||||||
422: `Validation Error`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Delete Profile Sample
|
|
||||||
* Delete a profile sample.
|
|
||||||
* @returns any Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static deleteProfileSampleProfilesSamplesSampleIdDelete({
|
|
||||||
sampleId,
|
|
||||||
}: {
|
|
||||||
sampleId: string;
|
|
||||||
}): CancelablePromise<any> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'DELETE',
|
|
||||||
url: '/profiles/samples/{sample_id}',
|
|
||||||
path: {
|
|
||||||
sample_id: sampleId,
|
|
||||||
},
|
|
||||||
errors: {
|
|
||||||
422: `Validation Error`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Generate Speech
|
|
||||||
* Generate speech from text using a voice profile.
|
|
||||||
* @returns GenerationResponse Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static generateSpeechGeneratePost({
|
|
||||||
requestBody,
|
|
||||||
}: {
|
|
||||||
requestBody: GenerationRequest;
|
|
||||||
}): CancelablePromise<GenerationResponse> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'POST',
|
|
||||||
url: '/generate',
|
|
||||||
body: requestBody,
|
|
||||||
mediaType: 'application/json',
|
|
||||||
errors: {
|
|
||||||
422: `Validation Error`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* List History
|
|
||||||
* List generation history with optional filters.
|
|
||||||
* @returns HistoryListResponse Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static listHistoryHistoryGet({
|
|
||||||
profileId,
|
|
||||||
search,
|
|
||||||
limit = 50,
|
|
||||||
offset,
|
|
||||||
}: {
|
|
||||||
profileId?: string | null;
|
|
||||||
search?: string | null;
|
|
||||||
limit?: number;
|
|
||||||
offset?: number;
|
|
||||||
}): CancelablePromise<HistoryListResponse> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'GET',
|
|
||||||
url: '/history',
|
|
||||||
query: {
|
|
||||||
profile_id: profileId,
|
|
||||||
search: search,
|
|
||||||
limit: limit,
|
|
||||||
offset: offset,
|
|
||||||
},
|
|
||||||
errors: {
|
|
||||||
422: `Validation Error`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get Generation
|
|
||||||
* Get a generation by ID.
|
|
||||||
* @returns HistoryResponse Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static getGenerationHistoryGenerationIdGet({
|
|
||||||
generationId,
|
|
||||||
}: {
|
|
||||||
generationId: string;
|
|
||||||
}): CancelablePromise<HistoryResponse> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'GET',
|
|
||||||
url: '/history/{generation_id}',
|
|
||||||
path: {
|
|
||||||
generation_id: generationId,
|
|
||||||
},
|
|
||||||
errors: {
|
|
||||||
422: `Validation Error`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Delete Generation
|
|
||||||
* Delete a generation.
|
|
||||||
* @returns any Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static deleteGenerationHistoryGenerationIdDelete({
|
|
||||||
generationId,
|
|
||||||
}: {
|
|
||||||
generationId: string;
|
|
||||||
}): CancelablePromise<any> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'DELETE',
|
|
||||||
url: '/history/{generation_id}',
|
|
||||||
path: {
|
|
||||||
generation_id: generationId,
|
|
||||||
},
|
|
||||||
errors: {
|
|
||||||
422: `Validation Error`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get Stats
|
|
||||||
* Get generation statistics.
|
|
||||||
* @returns any Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static getStatsHistoryStatsGet(): CancelablePromise<any> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'GET',
|
|
||||||
url: '/history/stats',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Transcribe Audio
|
|
||||||
* Transcribe audio file to text.
|
|
||||||
* @returns TranscriptionResponse Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static transcribeAudioTranscribePost({
|
|
||||||
formData,
|
|
||||||
}: {
|
|
||||||
formData: Body_transcribe_audio_transcribe_post;
|
|
||||||
}): CancelablePromise<TranscriptionResponse> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'POST',
|
|
||||||
url: '/transcribe',
|
|
||||||
formData: formData,
|
|
||||||
mediaType: 'multipart/form-data',
|
|
||||||
errors: {
|
|
||||||
422: `Validation Error`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get Audio
|
|
||||||
* Serve generated audio file.
|
|
||||||
* @returns any Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static getAudioAudioGenerationIdGet({
|
|
||||||
generationId,
|
|
||||||
}: {
|
|
||||||
generationId: string;
|
|
||||||
}): CancelablePromise<any> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'GET',
|
|
||||||
url: '/audio/{generation_id}',
|
|
||||||
path: {
|
|
||||||
generation_id: generationId,
|
|
||||||
},
|
|
||||||
errors: {
|
|
||||||
422: `Validation Error`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Load Model
|
|
||||||
* Manually load TTS model.
|
|
||||||
* @returns any Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static loadModelModelsLoadPost({
|
|
||||||
modelSize = '1.7B',
|
|
||||||
}: {
|
|
||||||
modelSize?: string;
|
|
||||||
}): CancelablePromise<any> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'POST',
|
|
||||||
url: '/models/load',
|
|
||||||
query: {
|
|
||||||
model_size: modelSize,
|
|
||||||
},
|
|
||||||
errors: {
|
|
||||||
422: `Validation Error`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Unload Model
|
|
||||||
* Unload TTS model to free memory.
|
|
||||||
* @returns any Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static unloadModelModelsUnloadPost(): CancelablePromise<any> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'POST',
|
|
||||||
url: '/models/unload',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get Model Progress
|
|
||||||
* Get model download progress via Server-Sent Events.
|
|
||||||
* @returns any Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static getModelProgressModelsProgressModelNameGet({
|
|
||||||
modelName,
|
|
||||||
}: {
|
|
||||||
modelName: string;
|
|
||||||
}): CancelablePromise<any> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'GET',
|
|
||||||
url: '/models/progress/{model_name}',
|
|
||||||
path: {
|
|
||||||
model_name: modelName,
|
|
||||||
},
|
|
||||||
errors: {
|
|
||||||
422: `Validation Error`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get Model Status
|
|
||||||
* Get status of all available models.
|
|
||||||
* @returns ModelStatusListResponse Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static getModelStatusModelsStatusGet(): CancelablePromise<ModelStatusListResponse> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'GET',
|
|
||||||
url: '/models/status',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Trigger Model Download
|
|
||||||
* Trigger download of a specific model.
|
|
||||||
* @returns any Successful Response
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static triggerModelDownloadModelsDownloadPost({
|
|
||||||
requestBody,
|
|
||||||
}: {
|
|
||||||
requestBody: ModelDownloadRequest;
|
|
||||||
}): CancelablePromise<any> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'POST',
|
|
||||||
url: '/models/download',
|
|
||||||
body: requestBody,
|
|
||||||
mediaType: 'application/json',
|
|
||||||
errors: {
|
|
||||||
422: `Validation Error`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import { QueryClientProvider } from '@tanstack/react-query';
|
|
||||||
// import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
|
||||||
import React from 'react';
|
|
||||||
import ReactDOM from 'react-dom/client';
|
|
||||||
import App from './App';
|
|
||||||
import './i18n';
|
|
||||||
import './index.css';
|
|
||||||
import { queryClient } from './lib/queryClient';
|
|
||||||
|
|
||||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
||||||
<React.StrictMode>
|
|
||||||
<QueryClientProvider client={queryClient}>
|
|
||||||
<App />
|
|
||||||
{/* <ReactQueryDevtools initialIsOpen={false} /> */}
|
|
||||||
</QueryClientProvider>
|
|
||||||
</React.StrictMode>,
|
|
||||||
);
|
|
||||||
+3
-3
@@ -113,7 +113,7 @@ const voicesRoute = createRoute({
|
|||||||
component: VoicesTab,
|
component: VoicesTab,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Captures route (prototype — will replace AudioTab once the new flow is ready)
|
// Captures route
|
||||||
const capturesRoute = createRoute({
|
const capturesRoute = createRoute({
|
||||||
getParentRoute: () => rootRoute,
|
getParentRoute: () => rootRoute,
|
||||||
path: '/captures',
|
path: '/captures',
|
||||||
@@ -199,8 +199,8 @@ const serverRedirectRoute = createRoute({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Route tree
|
// Route tree — exported so tests can build routers over memory history
|
||||||
const routeTree = rootRoute.addChildren([
|
export const routeTree = rootRoute.addChildren([
|
||||||
indexRoute,
|
indexRoute,
|
||||||
storiesRoute,
|
storiesRoute,
|
||||||
capturesRoute,
|
capturesRoute,
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
import path from 'node:path';
|
|
||||||
import tailwindcss from '@tailwindcss/vite';
|
|
||||||
import react from '@vitejs/plugin-react';
|
|
||||||
import { defineConfig } from 'vite';
|
|
||||||
import { changelogPlugin } from './plugins/changelog';
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
plugins: [tailwindcss(), react(), changelogPlugin(path.resolve(__dirname, '..'))],
|
|
||||||
resolve: {
|
|
||||||
alias: {
|
|
||||||
'@': path.resolve(__dirname, './src'),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user