Spaces:
Running
Running
axeronis commited on
Commit ·
bd115aa
1
Parent(s): 5339570
feat(voice): add Voice Settings UI with voice selection and upload
Browse files- backend/app/api/tenants.py +32 -2
- frontend/app/settings/voice/page.tsx +333 -0
backend/app/api/tenants.py
CHANGED
|
@@ -39,6 +39,11 @@ class TenantResponse(BaseModel):
|
|
| 39 |
tokens_balance: int
|
| 40 |
is_active: bool
|
| 41 |
referred_by: Optional[Dict[str, str]] = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
|
| 44 |
class UpdateTenantRequest(BaseModel):
|
|
@@ -54,6 +59,11 @@ class UpdateTenantRequest(BaseModel):
|
|
| 54 |
manager_monthly_salary: Optional[int] = None
|
| 55 |
company_name: Optional[str] = None
|
| 56 |
notification_settings: Optional[Dict[str, Any]] = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
|
| 59 |
|
|
@@ -136,10 +146,16 @@ async def get_my_tenant(
|
|
| 136 |
tokens_balance=tenant.tokens_balance,
|
| 137 |
is_active=tenant.is_active,
|
| 138 |
manager_monthly_salary=tenant.manager_monthly_salary,
|
| 139 |
-
referred_by=referred_by
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
)
|
| 141 |
|
| 142 |
|
|
|
|
| 143 |
@router.patch("/me", response_model=TenantResponse)
|
| 144 |
async def update_my_tenant(
|
| 145 |
request: UpdateTenantRequest,
|
|
@@ -220,6 +236,14 @@ async def update_my_tenant(
|
|
| 220 |
if request.notification_settings is not None:
|
| 221 |
tenant.notification_settings = request.notification_settings
|
| 222 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
session.add(tenant)
|
| 224 |
await session.commit()
|
| 225 |
await session.refresh(tenant)
|
|
@@ -239,10 +263,16 @@ async def update_my_tenant(
|
|
| 239 |
tokens_balance=tenant.tokens_balance,
|
| 240 |
is_active=tenant.is_active,
|
| 241 |
manager_monthly_salary=tenant.manager_monthly_salary,
|
| 242 |
-
referred_by=None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
)
|
| 244 |
|
| 245 |
|
|
|
|
| 246 |
@router.get("/me/usage")
|
| 247 |
async def get_my_usage_stats(
|
| 248 |
session: AsyncSession = Depends(get_async_session),
|
|
|
|
| 39 |
tokens_balance: int
|
| 40 |
is_active: bool
|
| 41 |
referred_by: Optional[Dict[str, str]] = None
|
| 42 |
+
|
| 43 |
+
# Voice Settings
|
| 44 |
+
voice_id: Optional[str] = "professional_male"
|
| 45 |
+
voice_enabled: Optional[bool] = True
|
| 46 |
+
voice_reference_url: Optional[str] = None
|
| 47 |
|
| 48 |
|
| 49 |
class UpdateTenantRequest(BaseModel):
|
|
|
|
| 59 |
manager_monthly_salary: Optional[int] = None
|
| 60 |
company_name: Optional[str] = None
|
| 61 |
notification_settings: Optional[Dict[str, Any]] = None
|
| 62 |
+
|
| 63 |
+
# Voice Settings
|
| 64 |
+
voice_id: Optional[str] = None
|
| 65 |
+
voice_enabled: Optional[bool] = None
|
| 66 |
+
voice_reference_url: Optional[str] = None
|
| 67 |
|
| 68 |
|
| 69 |
|
|
|
|
| 146 |
tokens_balance=tenant.tokens_balance,
|
| 147 |
is_active=tenant.is_active,
|
| 148 |
manager_monthly_salary=tenant.manager_monthly_salary,
|
| 149 |
+
referred_by=referred_by,
|
| 150 |
+
|
| 151 |
+
# Voice Settings
|
| 152 |
+
voice_id=getattr(tenant, 'voice_id', 'professional_male'),
|
| 153 |
+
voice_enabled=getattr(tenant, 'voice_enabled', True),
|
| 154 |
+
voice_reference_url=getattr(tenant, 'voice_reference_url', None)
|
| 155 |
)
|
| 156 |
|
| 157 |
|
| 158 |
+
|
| 159 |
@router.patch("/me", response_model=TenantResponse)
|
| 160 |
async def update_my_tenant(
|
| 161 |
request: UpdateTenantRequest,
|
|
|
|
| 236 |
if request.notification_settings is not None:
|
| 237 |
tenant.notification_settings = request.notification_settings
|
| 238 |
|
| 239 |
+
# Voice Settings
|
| 240 |
+
if request.voice_id is not None:
|
| 241 |
+
tenant.voice_id = request.voice_id
|
| 242 |
+
if request.voice_enabled is not None:
|
| 243 |
+
tenant.voice_enabled = request.voice_enabled
|
| 244 |
+
if request.voice_reference_url is not None:
|
| 245 |
+
tenant.voice_reference_url = request.voice_reference_url
|
| 246 |
+
|
| 247 |
session.add(tenant)
|
| 248 |
await session.commit()
|
| 249 |
await session.refresh(tenant)
|
|
|
|
| 263 |
tokens_balance=tenant.tokens_balance,
|
| 264 |
is_active=tenant.is_active,
|
| 265 |
manager_monthly_salary=tenant.manager_monthly_salary,
|
| 266 |
+
referred_by=None,
|
| 267 |
+
|
| 268 |
+
# Voice Settings
|
| 269 |
+
voice_id=getattr(tenant, 'voice_id', 'professional_male'),
|
| 270 |
+
voice_enabled=getattr(tenant, 'voice_enabled', True),
|
| 271 |
+
voice_reference_url=getattr(tenant, 'voice_reference_url', None)
|
| 272 |
)
|
| 273 |
|
| 274 |
|
| 275 |
+
|
| 276 |
@router.get("/me/usage")
|
| 277 |
async def get_my_usage_stats(
|
| 278 |
session: AsyncSession = Depends(get_async_session),
|
frontend/app/settings/voice/page.tsx
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import { useState, useEffect, useCallback } from 'react'
|
| 4 |
+
import { useAuth } from '@/contexts/AuthContext'
|
| 5 |
+
import { Mic, MicOff, Upload, Trash2, Save, Loader2, CheckCircle2, Play, Volume2 } from 'lucide-react'
|
| 6 |
+
import { motion } from 'framer-motion'
|
| 7 |
+
import { cn } from '@/lib/utils'
|
| 8 |
+
import { api } from '@/lib/api'
|
| 9 |
+
import { useToast } from '@/contexts/ToastContext'
|
| 10 |
+
|
| 11 |
+
interface VoiceSettings {
|
| 12 |
+
voice_id: string
|
| 13 |
+
voice_enabled: boolean
|
| 14 |
+
voice_reference_url: string | null
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
const VOICE_OPTIONS = [
|
| 18 |
+
{
|
| 19 |
+
id: 'professional_male',
|
| 20 |
+
name: 'Professional (Male)',
|
| 21 |
+
description: 'Уверенный деловой голос, работает на русском и английском',
|
| 22 |
+
icon: '👔'
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
id: 'friendly_male',
|
| 26 |
+
name: 'Friendly (Male)',
|
| 27 |
+
description: 'Тёплый, дружелюбный голос для налаживания контакта',
|
| 28 |
+
icon: '😊'
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
id: 'professional_female',
|
| 32 |
+
name: 'Professional (Female)',
|
| 33 |
+
description: 'Чёткий, вызывающий доверие женский голос',
|
| 34 |
+
icon: '👩💼'
|
| 35 |
+
}
|
| 36 |
+
]
|
| 37 |
+
|
| 38 |
+
export default function VoiceSettingsPage() {
|
| 39 |
+
const { accessToken } = useAuth()
|
| 40 |
+
const { addToast } = useToast()
|
| 41 |
+
const [settings, setSettings] = useState<VoiceSettings>({
|
| 42 |
+
voice_id: 'professional_male',
|
| 43 |
+
voice_enabled: true,
|
| 44 |
+
voice_reference_url: null
|
| 45 |
+
})
|
| 46 |
+
const [loading, setLoading] = useState(true)
|
| 47 |
+
const [saving, setSaving] = useState(false)
|
| 48 |
+
const [uploading, setUploading] = useState(false)
|
| 49 |
+
|
| 50 |
+
// Fetch current settings
|
| 51 |
+
useEffect(() => {
|
| 52 |
+
const fetchSettings = async () => {
|
| 53 |
+
try {
|
| 54 |
+
const response = await api.get('/api/tenants/me', {
|
| 55 |
+
headers: { Authorization: `Bearer ${accessToken}` }
|
| 56 |
+
})
|
| 57 |
+
setSettings({
|
| 58 |
+
voice_id: response.data.voice_id || 'professional_male',
|
| 59 |
+
voice_enabled: response.data.voice_enabled ?? true,
|
| 60 |
+
voice_reference_url: response.data.voice_reference_url || null
|
| 61 |
+
})
|
| 62 |
+
} catch (error) {
|
| 63 |
+
console.error('Failed to fetch voice settings:', error)
|
| 64 |
+
} finally {
|
| 65 |
+
setLoading(false)
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
if (accessToken) {
|
| 70 |
+
fetchSettings()
|
| 71 |
+
}
|
| 72 |
+
}, [accessToken])
|
| 73 |
+
|
| 74 |
+
// Save settings
|
| 75 |
+
const saveSettings = async () => {
|
| 76 |
+
setSaving(true)
|
| 77 |
+
try {
|
| 78 |
+
await api.patch('/api/tenants/me', settings, {
|
| 79 |
+
headers: { Authorization: `Bearer ${accessToken}` }
|
| 80 |
+
})
|
| 81 |
+
addToast('success', 'Настройки голоса сохранены!')
|
| 82 |
+
} catch (error) {
|
| 83 |
+
console.error('Failed to save voice settings:', error)
|
| 84 |
+
addToast('error', 'Ошибка сохранения настроек')
|
| 85 |
+
} finally {
|
| 86 |
+
setSaving(false)
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
// Handle file upload for custom voice
|
| 91 |
+
const handleFileUpload = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
| 92 |
+
const file = event.target.files?.[0]
|
| 93 |
+
if (!file) return
|
| 94 |
+
|
| 95 |
+
// Validate file size (max 10MB)
|
| 96 |
+
if (file.size > 10 * 1024 * 1024) {
|
| 97 |
+
addToast('error', 'Файл слишком большой. Максимум 10MB.')
|
| 98 |
+
return
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
setUploading(true)
|
| 102 |
+
try {
|
| 103 |
+
// For now, we'll use a placeholder - in production this would upload to CHATTERBOX_API_URL/voices/upload
|
| 104 |
+
// and store the URL in voice_reference_url
|
| 105 |
+
addToast('warning', 'Загрузка голоса пока недоступна. Развертите Chatterbox сервис.')
|
| 106 |
+
|
| 107 |
+
// TODO: Implement actual upload to Chatterbox service
|
| 108 |
+
// const formData = new FormData()
|
| 109 |
+
// formData.append('voice_id', 'custom_' + Date.now())
|
| 110 |
+
// formData.append('audio', file)
|
| 111 |
+
// const response = await fetch(CHATTERBOX_API_URL + '/voices/upload', { method: 'POST', body: formData })
|
| 112 |
+
|
| 113 |
+
} catch (error) {
|
| 114 |
+
console.error('Failed to upload voice:', error)
|
| 115 |
+
addToast('error', 'Ошибка загрузки голоса')
|
| 116 |
+
} finally {
|
| 117 |
+
setUploading(false)
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
// Remove custom voice
|
| 122 |
+
const removeCustomVoice = () => {
|
| 123 |
+
setSettings(prev => ({
|
| 124 |
+
...prev,
|
| 125 |
+
voice_reference_url: null,
|
| 126 |
+
voice_id: 'professional_male'
|
| 127 |
+
}))
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
if (loading) {
|
| 131 |
+
return (
|
| 132 |
+
<div className="flex items-center justify-center min-h-[400px]">
|
| 133 |
+
<Loader2 className="w-8 h-8 animate-spin text-indigo-500" />
|
| 134 |
+
</div>
|
| 135 |
+
)
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
return (
|
| 139 |
+
<div className="max-w-4xl mx-auto p-6 space-y-8">
|
| 140 |
+
{/* Header */}
|
| 141 |
+
<div className="flex items-center justify-between">
|
| 142 |
+
<div>
|
| 143 |
+
<h1 className="text-2xl font-bold text-white flex items-center gap-3">
|
| 144 |
+
<Volume2 className="w-7 h-7 text-indigo-400" />
|
| 145 |
+
Настройки голоса AI
|
| 146 |
+
</h1>
|
| 147 |
+
<p className="text-zinc-400 mt-1">
|
| 148 |
+
Настройте голос, которым AI будет отвечать клиентам
|
| 149 |
+
</p>
|
| 150 |
+
</div>
|
| 151 |
+
|
| 152 |
+
<button
|
| 153 |
+
onClick={saveSettings}
|
| 154 |
+
disabled={saving}
|
| 155 |
+
className="flex items-center gap-2 px-4 py-2 bg-indigo-600 hover:bg-indigo-700 rounded-lg text-white font-medium transition-colors disabled:opacity-50"
|
| 156 |
+
>
|
| 157 |
+
{saving ? (
|
| 158 |
+
<Loader2 className="w-4 h-4 animate-spin" />
|
| 159 |
+
) : (
|
| 160 |
+
<Save className="w-4 h-4" />
|
| 161 |
+
)}
|
| 162 |
+
Сохранить
|
| 163 |
+
</button>
|
| 164 |
+
</div>
|
| 165 |
+
|
| 166 |
+
{/* Voice Enabled Toggle */}
|
| 167 |
+
<motion.div
|
| 168 |
+
initial={{ opacity: 0, y: 20 }}
|
| 169 |
+
animate={{ opacity: 1, y: 0 }}
|
| 170 |
+
className="bg-zinc-900 rounded-xl border border-zinc-800 p-6"
|
| 171 |
+
>
|
| 172 |
+
<div className="flex items-center justify-between">
|
| 173 |
+
<div className="flex items-center gap-4">
|
| 174 |
+
<div className={cn(
|
| 175 |
+
"w-12 h-12 rounded-xl flex items-center justify-center",
|
| 176 |
+
settings.voice_enabled ? "bg-indigo-500/20 text-indigo-400" : "bg-zinc-800 text-zinc-500"
|
| 177 |
+
)}>
|
| 178 |
+
{settings.voice_enabled ? <Mic className="w-6 h-6" /> : <MicOff className="w-6 h-6" />}
|
| 179 |
+
</div>
|
| 180 |
+
<div>
|
| 181 |
+
<h3 className="text-lg font-medium text-white">Голосовые ответы AI</h3>
|
| 182 |
+
<p className="text-zinc-400">
|
| 183 |
+
{settings.voice_enabled
|
| 184 |
+
? 'AI будет отвечать голосовыми сообщениями когда это уместно'
|
| 185 |
+
: 'AI отвечает только текстом'
|
| 186 |
+
}
|
| 187 |
+
</p>
|
| 188 |
+
</div>
|
| 189 |
+
</div>
|
| 190 |
+
|
| 191 |
+
<button
|
| 192 |
+
onClick={() => setSettings(prev => ({ ...prev, voice_enabled: !prev.voice_enabled }))}
|
| 193 |
+
className={cn(
|
| 194 |
+
"relative w-14 h-8 rounded-full transition-colors",
|
| 195 |
+
settings.voice_enabled ? "bg-indigo-600" : "bg-zinc-700"
|
| 196 |
+
)}
|
| 197 |
+
>
|
| 198 |
+
<motion.div
|
| 199 |
+
animate={{ x: settings.voice_enabled ? 24 : 4 }}
|
| 200 |
+
transition={{ type: "spring", stiffness: 500, damping: 30 }}
|
| 201 |
+
className="absolute top-1 w-6 h-6 bg-white rounded-full shadow-md"
|
| 202 |
+
/>
|
| 203 |
+
</button>
|
| 204 |
+
</div>
|
| 205 |
+
</motion.div>
|
| 206 |
+
|
| 207 |
+
{/* Voice Selection */}
|
| 208 |
+
<motion.div
|
| 209 |
+
initial={{ opacity: 0, y: 20 }}
|
| 210 |
+
animate={{ opacity: 1, y: 0 }}
|
| 211 |
+
transition={{ delay: 0.1 }}
|
| 212 |
+
className="bg-zinc-900 rounded-xl border border-zinc-800 p-6"
|
| 213 |
+
>
|
| 214 |
+
<h3 className="text-lg font-medium text-white mb-4">Выберите голос</h3>
|
| 215 |
+
|
| 216 |
+
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
| 217 |
+
{VOICE_OPTIONS.map((voice) => (
|
| 218 |
+
<button
|
| 219 |
+
key={voice.id}
|
| 220 |
+
onClick={() => setSettings(prev => ({ ...prev, voice_id: voice.id }))}
|
| 221 |
+
className={cn(
|
| 222 |
+
"p-4 rounded-xl border-2 text-left transition-all",
|
| 223 |
+
settings.voice_id === voice.id
|
| 224 |
+
? "border-indigo-500 bg-indigo-500/10"
|
| 225 |
+
: "border-zinc-700 bg-zinc-800/50 hover:border-zinc-600"
|
| 226 |
+
)}
|
| 227 |
+
>
|
| 228 |
+
<div className="text-3xl mb-2">{voice.icon}</div>
|
| 229 |
+
<h4 className="font-medium text-white">{voice.name}</h4>
|
| 230 |
+
<p className="text-sm text-zinc-400 mt-1">{voice.description}</p>
|
| 231 |
+
|
| 232 |
+
{settings.voice_id === voice.id && (
|
| 233 |
+
<div className="flex items-center gap-1 mt-3 text-indigo-400 text-sm">
|
| 234 |
+
<CheckCircle2 className="w-4 h-4" />
|
| 235 |
+
Выбран
|
| 236 |
+
</div>
|
| 237 |
+
)}
|
| 238 |
+
</button>
|
| 239 |
+
))}
|
| 240 |
+
</div>
|
| 241 |
+
</motion.div>
|
| 242 |
+
|
| 243 |
+
{/* Custom Voice Upload */}
|
| 244 |
+
<motion.div
|
| 245 |
+
initial={{ opacity: 0, y: 20 }}
|
| 246 |
+
animate={{ opacity: 1, y: 0 }}
|
| 247 |
+
transition={{ delay: 0.2 }}
|
| 248 |
+
className="bg-zinc-900 rounded-xl border border-zinc-800 p-6"
|
| 249 |
+
>
|
| 250 |
+
<h3 className="text-lg font-medium text-white mb-2">Клонировать свой голос</h3>
|
| 251 |
+
<p className="text-zinc-400 mb-4">
|
| 252 |
+
Загрузите аудио 10-30 секунд чистой речи для клонирования вашего голоса
|
| 253 |
+
</p>
|
| 254 |
+
|
| 255 |
+
{settings.voice_reference_url ? (
|
| 256 |
+
<div className="flex items-center gap-4 p-4 bg-zinc-800/50 rounded-xl">
|
| 257 |
+
<div className="w-12 h-12 rounded-xl bg-green-500/20 flex items-center justify-center">
|
| 258 |
+
<CheckCircle2 className="w-6 h-6 text-green-400" />
|
| 259 |
+
</div>
|
| 260 |
+
<div className="flex-1">
|
| 261 |
+
<p className="text-white font-medium">Кастомный голос загружен</p>
|
| 262 |
+
<p className="text-sm text-zinc-400">Ваш голос используется для ответов AI</p>
|
| 263 |
+
</div>
|
| 264 |
+
<button
|
| 265 |
+
onClick={removeCustomVoice}
|
| 266 |
+
className="p-2 text-red-400 hover:bg-red-500/10 rounded-lg transition-colors"
|
| 267 |
+
>
|
| 268 |
+
<Trash2 className="w-5 h-5" />
|
| 269 |
+
</button>
|
| 270 |
+
</div>
|
| 271 |
+
) : (
|
| 272 |
+
<label className="block">
|
| 273 |
+
<input
|
| 274 |
+
type="file"
|
| 275 |
+
accept="audio/*"
|
| 276 |
+
onChange={handleFileUpload}
|
| 277 |
+
className="hidden"
|
| 278 |
+
disabled={uploading}
|
| 279 |
+
/>
|
| 280 |
+
<div className={cn(
|
| 281 |
+
"flex flex-col items-center justify-center p-8 border-2 border-dashed rounded-xl cursor-pointer transition-colors",
|
| 282 |
+
uploading
|
| 283 |
+
? "border-zinc-600 bg-zinc-800/30"
|
| 284 |
+
: "border-zinc-700 hover:border-indigo-500 hover:bg-indigo-500/5"
|
| 285 |
+
)}>
|
| 286 |
+
{uploading ? (
|
| 287 |
+
<Loader2 className="w-8 h-8 animate-spin text-indigo-400 mb-2" />
|
| 288 |
+
) : (
|
| 289 |
+
<Upload className="w-8 h-8 text-zinc-400 mb-2" />
|
| 290 |
+
)}
|
| 291 |
+
<p className="text-white font-medium">
|
| 292 |
+
{uploading ? 'Загрузка...' : 'Нажмите для загрузки аудио'}
|
| 293 |
+
</p>
|
| 294 |
+
<p className="text-sm text-zinc-500 mt-1">
|
| 295 |
+
WAV, MP3, OGG • Максимум 10MB
|
| 296 |
+
</p>
|
| 297 |
+
</div>
|
| 298 |
+
</label>
|
| 299 |
+
)}
|
| 300 |
+
</motion.div>
|
| 301 |
+
|
| 302 |
+
{/* Info Section */}
|
| 303 |
+
<motion.div
|
| 304 |
+
initial={{ opacity: 0, y: 20 }}
|
| 305 |
+
animate={{ opacity: 1, y: 0 }}
|
| 306 |
+
transition={{ delay: 0.3 }}
|
| 307 |
+
className="bg-gradient-to-r from-indigo-500/10 to-purple-500/10 rounded-xl border border-indigo-500/20 p-6"
|
| 308 |
+
>
|
| 309 |
+
<h3 className="text-lg font-medium text-white mb-2 flex items-center gap-2">
|
| 310 |
+
💡 Когда AI использует голос?
|
| 311 |
+
</h3>
|
| 312 |
+
<ul className="space-y-2 text-zinc-300">
|
| 313 |
+
<li className="flex items-start gap-2">
|
| 314 |
+
<span className="text-indigo-400">•</span>
|
| 315 |
+
Когда клиент отправляет голосовое сообщение (voice-to-voice)
|
| 316 |
+
</li>
|
| 317 |
+
<li className="flex items-start gap-2">
|
| 318 |
+
<span className="text-indigo-400">•</span>
|
| 319 |
+
При закрытии сделки (для усиления эффекта)
|
| 320 |
+
</li>
|
| 321 |
+
<li className="flex items-start gap-2">
|
| 322 |
+
<span className="text-indigo-400">•</span>
|
| 323 |
+
При преодолении возражений (показывает уверенность)
|
| 324 |
+
</li>
|
| 325 |
+
<li className="flex items-start gap-2">
|
| 326 |
+
<span className="text-indigo-400">•</span>
|
| 327 |
+
Для создания доверия ("Я лично гарантирую...")
|
| 328 |
+
</li>
|
| 329 |
+
</ul>
|
| 330 |
+
</motion.div>
|
| 331 |
+
</div>
|
| 332 |
+
)
|
| 333 |
+
}
|