Spaces:
Sleeping

axeronis commited on
Commit
3e1a476
·
1 Parent(s): dde3672

feat(voice): improved Voice Settings UI with audio preview and better design

Browse files
Files changed (1) hide show
  1. frontend/app/settings/voice/page.tsx +277 -99
frontend/app/settings/voice/page.tsx CHANGED
@@ -1,9 +1,12 @@
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'
@@ -14,27 +17,61 @@ interface VoiceSettings {
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 { token } = useAuth()
40
  const toast = useToast()
@@ -46,6 +83,16 @@ export default function VoiceSettingsPage() {
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(() => {
@@ -71,6 +118,38 @@ export default function VoiceSettingsPage() {
71
  }
72
  }, [token])
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  // Save settings
75
  const saveSettings = async () => {
76
  setSaving(true)
@@ -92,7 +171,6 @@ export default function VoiceSettingsPage() {
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
  toast.error('Файл слишком большой. Максимум 10MB.')
98
  return
@@ -100,16 +178,7 @@ export default function VoiceSettingsPage() {
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
- toast.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
  toast.error('Ошибка загрузки голоса')
@@ -118,7 +187,6 @@ export default function VoiceSettingsPage() {
118
  }
119
  }
120
 
121
- // Remove custom voice
122
  const removeCustomVoice = () => {
123
  setSettings(prev => ({
124
  ...prev,
@@ -127,6 +195,9 @@ export default function VoiceSettingsPage() {
127
  }))
128
  }
129
 
 
 
 
130
  if (loading) {
131
  return (
132
  <div className="flex items-center justify-center min-h-[400px]">
@@ -136,23 +207,25 @@ export default function VoiceSettingsPage() {
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" />
@@ -163,25 +236,49 @@ export default function VoiceSettingsPage() {
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>
@@ -191,14 +288,16 @@ export default function VoiceSettingsPage() {
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>
@@ -209,34 +308,104 @@ export default function VoiceSettingsPage() {
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
 
@@ -245,11 +414,17 @@ export default function VoiceSettingsPage() {
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 ? (
@@ -275,21 +450,28 @@ export default function VoiceSettingsPage() {
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
@@ -299,34 +481,30 @@ export default function VoiceSettingsPage() {
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
  )
 
1
  'use client'
2
 
3
+ import { useState, useEffect, useRef } from 'react'
4
  import { useAuth } from '@/contexts/AuthContext'
5
+ import {
6
+ Mic, MicOff, Upload, Trash2, Save, Loader2, CheckCircle2,
7
+ Play, Pause, Volume2, AlertCircle, Sparkles, Info
8
+ } from 'lucide-react'
9
+ import { motion, AnimatePresence } from 'framer-motion'
10
  import { cn } from '@/lib/utils'
11
  import { api } from '@/lib/api'
12
  import { useToast } from '@/contexts/ToastContext'
 
17
  voice_reference_url: string | null
18
  }
19
 
20
+ // Voice options with demo phrases
21
  const VOICE_OPTIONS = [
22
  {
23
  id: 'professional_male',
24
+ name: 'Профессионал',
25
+ gender: 'Мужской',
26
+ description: 'Уверенный деловой голос. Идеален для B2B продаж и консалтинга.',
27
+ icon: '👔',
28
+ color: 'indigo',
29
+ demoText: 'Здравствуйте! Я ваш персональный менеджер. Готов помочь вам найти идеальное решение для вашего бизнеса.',
30
+ traits: ['Уверенный', 'Деловой', 'Авторитетный']
31
  },
32
  {
33
  id: 'friendly_male',
34
+ name: 'Дружелюбный',
35
+ gender: 'Мужской',
36
+ description: 'Тёплый голос для налаживания контакта. Отлично подходит для B2C.',
37
+ icon: '😊',
38
+ color: 'emerald',
39
+ demoText: 'Привет! Рад, что вы написали. Давайте вместе разберёмся, что вам нужно — я уверен, мы найдём отличный вариант!',
40
+ traits: ['Дружелюбный', 'Тёплый', 'Располагающий']
41
  },
42
  {
43
  id: 'professional_female',
44
+ name: 'Элегантный',
45
+ gender: 'Женский',
46
+ description: 'Профессиональный женский голос. Вызывает доверие и симпатию.',
47
+ icon: '👩‍💼',
48
+ color: 'purple',
49
+ demoText: 'Добрый день! Спасибо за ваш интерес. Позвольте рассказать вам о наших возможностях подробнее.',
50
+ traits: ['Элегантный', 'Доверительный', 'Приятный']
51
  }
52
  ]
53
 
54
+ const COLOR_MAP: Record<string, { bg: string, border: string, text: string, badge: string }> = {
55
+ indigo: {
56
+ bg: 'bg-indigo-500/10',
57
+ border: 'border-indigo-500',
58
+ text: 'text-indigo-400',
59
+ badge: 'bg-indigo-500/20 text-indigo-300'
60
+ },
61
+ emerald: {
62
+ bg: 'bg-emerald-500/10',
63
+ border: 'border-emerald-500',
64
+ text: 'text-emerald-400',
65
+ badge: 'bg-emerald-500/20 text-emerald-300'
66
+ },
67
+ purple: {
68
+ bg: 'bg-purple-500/10',
69
+ border: 'border-purple-500',
70
+ text: 'text-purple-400',
71
+ badge: 'bg-purple-500/20 text-purple-300'
72
+ }
73
+ }
74
+
75
  export default function VoiceSettingsPage() {
76
  const { token } = useAuth()
77
  const toast = useToast()
 
83
  const [loading, setLoading] = useState(true)
84
  const [saving, setSaving] = useState(false)
85
  const [uploading, setUploading] = useState(false)
86
+ const [playingVoice, setPlayingVoice] = useState<string | null>(null)
87
+ const [isServiceAvailable, setIsServiceAvailable] = useState<boolean | null>(null)
88
+ const speechSynthRef = useRef<SpeechSynthesisUtterance | null>(null)
89
+
90
+ // Check if Chatterbox service is available
91
+ useEffect(() => {
92
+ // For now, we'll show as unavailable until user deploys
93
+ // In production, this would check CHATTERBOX_API_URL/health
94
+ setIsServiceAvailable(false)
95
+ }, [])
96
 
97
  // Fetch current settings
98
  useEffect(() => {
 
118
  }
119
  }, [token])
120
 
121
+ // Play demo voice using browser TTS
122
+ const playDemoVoice = (voiceId: string, text: string) => {
123
+ if (playingVoice === voiceId) {
124
+ // Stop playing
125
+ window.speechSynthesis.cancel()
126
+ setPlayingVoice(null)
127
+ return
128
+ }
129
+
130
+ // Stop any current playback
131
+ window.speechSynthesis.cancel()
132
+
133
+ const utterance = new SpeechSynthesisUtterance(text)
134
+ utterance.lang = 'ru-RU'
135
+ utterance.rate = 0.9
136
+ utterance.pitch = 1.0
137
+
138
+ // Try to find a suitable voice
139
+ const voices = window.speechSynthesis.getVoices()
140
+ const russianVoice = voices.find(v => v.lang.startsWith('ru'))
141
+ if (russianVoice) {
142
+ utterance.voice = russianVoice
143
+ }
144
+
145
+ utterance.onend = () => setPlayingVoice(null)
146
+ utterance.onerror = () => setPlayingVoice(null)
147
+
148
+ speechSynthRef.current = utterance
149
+ setPlayingVoice(voiceId)
150
+ window.speechSynthesis.speak(utterance)
151
+ }
152
+
153
  // Save settings
154
  const saveSettings = async () => {
155
  setSaving(true)
 
171
  const file = event.target.files?.[0]
172
  if (!file) return
173
 
 
174
  if (file.size > 10 * 1024 * 1024) {
175
  toast.error('Файл слишком большой. Максимум 10MB.')
176
  return
 
178
 
179
  setUploading(true)
180
  try {
181
+ toast.warning('Загрузка голоса пока недоступна. Сначала разверните Chatterbox сервис.')
 
 
 
 
 
 
 
 
 
182
  } catch (error) {
183
  console.error('Failed to upload voice:', error)
184
  toast.error('Ошибка загрузки голоса')
 
187
  }
188
  }
189
 
 
190
  const removeCustomVoice = () => {
191
  setSettings(prev => ({
192
  ...prev,
 
195
  }))
196
  }
197
 
198
+ const selectedVoice = VOICE_OPTIONS.find(v => v.id === settings.voice_id)
199
+ const selectedColor = selectedVoice ? COLOR_MAP[selectedVoice.color] : COLOR_MAP.indigo
200
+
201
  if (loading) {
202
  return (
203
  <div className="flex items-center justify-center min-h-[400px]">
 
207
  }
208
 
209
  return (
210
+ <div className="max-w-5xl mx-auto p-6 space-y-8">
211
  {/* Header */}
212
  <div className="flex items-center justify-between">
213
  <div>
214
  <h1 className="text-2xl font-bold text-white flex items-center gap-3">
215
+ <div className="p-2 rounded-xl bg-gradient-to-br from-indigo-500 to-purple-600">
216
+ <Volume2 className="w-6 h-6 text-white" />
217
+ </div>
218
+ Голос AI-менеджера
219
  </h1>
220
  <p className="text-zinc-400 mt-1">
221
+ Выберите голос, которым AI будет общаться с клиентами
222
  </p>
223
  </div>
224
 
225
  <button
226
  onClick={saveSettings}
227
  disabled={saving}
228
+ className="flex items-center gap-2 px-5 py-2.5 bg-gradient-to-r from-indigo-600 to-purple-600 hover:from-indigo-500 hover:to-purple-500 rounded-xl text-white font-medium transition-all shadow-lg shadow-indigo-500/25 disabled:opacity-50"
229
  >
230
  {saving ? (
231
  <Loader2 className="w-4 h-4 animate-spin" />
 
236
  </button>
237
  </div>
238
 
239
+ {/* Service Status Banner */}
240
+ {isServiceAvailable === false && (
241
+ <motion.div
242
+ initial={{ opacity: 0, y: -10 }}
243
+ animate={{ opacity: 1, y: 0 }}
244
+ className="bg-amber-500/10 border border-amber-500/30 rounded-xl p-4 flex items-start gap-3"
245
+ >
246
+ <AlertCircle className="w-5 h-5 text-amber-400 flex-shrink-0 mt-0.5" />
247
+ <div>
248
+ <p className="text-amber-200 font-medium">Голосовой сервис не подключен</p>
249
+ <p className="text-amber-300/70 text-sm mt-1">
250
+ Для работы голосовых ответов разверните Chatterbox сервис.
251
+ Пока что используется демо-режим браузера.
252
+ </p>
253
+ </div>
254
+ </motion.div>
255
+ )}
256
+
257
  {/* Voice Enabled Toggle */}
258
  <motion.div
259
  initial={{ opacity: 0, y: 20 }}
260
  animate={{ opacity: 1, y: 0 }}
261
+ className="bg-zinc-900/80 backdrop-blur rounded-2xl border border-zinc-800 p-6"
262
  >
263
  <div className="flex items-center justify-between">
264
  <div className="flex items-center gap-4">
265
  <div className={cn(
266
+ "w-14 h-14 rounded-2xl flex items-center justify-center transition-all",
267
+ settings.voice_enabled
268
+ ? "bg-gradient-to-br from-indigo-500 to-purple-600 shadow-lg shadow-indigo-500/30"
269
+ : "bg-zinc-800"
270
  )}>
271
+ {settings.voice_enabled ? (
272
+ <Mic className="w-7 h-7 text-white" />
273
+ ) : (
274
+ <MicOff className="w-7 h-7 text-zinc-500" />
275
+ )}
276
  </div>
277
  <div>
278
+ <h3 className="text-lg font-semibold text-white">Голосовые ответы AI</h3>
279
+ <p className="text-zinc-400 text-sm">
280
  {settings.voice_enabled
281
+ ? 'AI отправляет голосовые сообщения в ключевые моменты'
282
  : 'AI отвечает только текстом'
283
  }
284
  </p>
 
288
  <button
289
  onClick={() => setSettings(prev => ({ ...prev, voice_enabled: !prev.voice_enabled }))}
290
  className={cn(
291
+ "relative w-16 h-9 rounded-full transition-all",
292
+ settings.voice_enabled
293
+ ? "bg-gradient-to-r from-indigo-600 to-purple-600"
294
+ : "bg-zinc-700"
295
  )}
296
  >
297
  <motion.div
298
+ animate={{ x: settings.voice_enabled ? 30 : 4 }}
299
  transition={{ type: "spring", stiffness: 500, damping: 30 }}
300
+ className="absolute top-1.5 w-6 h-6 bg-white rounded-full shadow-lg"
301
  />
302
  </button>
303
  </div>
 
308
  initial={{ opacity: 0, y: 20 }}
309
  animate={{ opacity: 1, y: 0 }}
310
  transition={{ delay: 0.1 }}
311
+ className="space-y-4"
312
  >
313
+ <div className="flex items-center gap-2">
314
+ <Sparkles className="w-5 h-5 text-indigo-400" />
315
+ <h3 className="text-lg font-semibold text-white">Выберите голос</h3>
316
+ </div>
317
+ <p className="text-zinc-400 text-sm">
318
+ Нажмите ▶ чтобы прослушать демо голоса
319
+ </p>
320
 
321
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-4">
322
+ {VOICE_OPTIONS.map((voice) => {
323
+ const isSelected = settings.voice_id === voice.id
324
+ const isPlaying = playingVoice === voice.id
325
+ const colors = COLOR_MAP[voice.color]
326
+
327
+ return (
328
+ <motion.div
329
+ key={voice.id}
330
+ whileHover={{ scale: 1.02 }}
331
+ whileTap={{ scale: 0.98 }}
332
+ className={cn(
333
+ "relative p-5 rounded-2xl border-2 cursor-pointer transition-all",
334
+ isSelected
335
+ ? `${colors.border} ${colors.bg}`
336
+ : "border-zinc-700/50 bg-zinc-900/50 hover:border-zinc-600"
337
+ )}
338
+ onClick={() => setSettings(prev => ({ ...prev, voice_id: voice.id }))}
339
+ >
340
+ {/* Selected badge */}
341
+ <AnimatePresence>
342
+ {isSelected && (
343
+ <motion.div
344
+ initial={{ opacity: 0, scale: 0.5 }}
345
+ animate={{ opacity: 1, scale: 1 }}
346
+ exit={{ opacity: 0, scale: 0.5 }}
347
+ className="absolute -top-2 -right-2 w-6 h-6 bg-white rounded-full flex items-center justify-center shadow-lg"
348
+ >
349
+ <CheckCircle2 className={cn("w-5 h-5", colors.text)} />
350
+ </motion.div>
351
+ )}
352
+ </AnimatePresence>
353
+
354
+ {/* Icon and name */}
355
+ <div className="flex items-center gap-3 mb-3">
356
+ <span className="text-3xl">{voice.icon}</span>
357
+ <div>
358
+ <h4 className="font-semibold text-white">{voice.name}</h4>
359
+ <span className="text-xs text-zinc-500">{voice.gender}</span>
360
+ </div>
361
  </div>
362
+
363
+ {/* Description */}
364
+ <p className="text-sm text-zinc-400 mb-3">{voice.description}</p>
365
+
366
+ {/* Traits */}
367
+ <div className="flex flex-wrap gap-1 mb-4">
368
+ {voice.traits.map(trait => (
369
+ <span
370
+ key={trait}
371
+ className={cn(
372
+ "px-2 py-0.5 rounded-full text-xs",
373
+ isSelected ? colors.badge : "bg-zinc-800 text-zinc-400"
374
+ )}
375
+ >
376
+ {trait}
377
+ </span>
378
+ ))}
379
+ </div>
380
+
381
+ {/* Play button */}
382
+ <button
383
+ onClick={(e) => {
384
+ e.stopPropagation()
385
+ playDemoVoice(voice.id, voice.demoText)
386
+ }}
387
+ className={cn(
388
+ "w-full flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all font-medium text-sm",
389
+ isPlaying
390
+ ? `${colors.bg} ${colors.text} border ${colors.border}`
391
+ : "bg-zinc-800 hover:bg-zinc-700 text-zinc-300"
392
+ )}
393
+ >
394
+ {isPlaying ? (
395
+ <>
396
+ <Pause className="w-4 h-4" />
397
+ Остановить
398
+ </>
399
+ ) : (
400
+ <>
401
+ <Play className="w-4 h-4" />
402
+ Прослушать
403
+ </>
404
+ )}
405
+ </button>
406
+ </motion.div>
407
+ )
408
+ })}
409
  </div>
410
  </motion.div>
411
 
 
414
  initial={{ opacity: 0, y: 20 }}
415
  animate={{ opacity: 1, y: 0 }}
416
  transition={{ delay: 0.2 }}
417
+ className="bg-zinc-900/80 backdrop-blur rounded-2xl border border-zinc-800 p-6"
418
  >
419
+ <div className="flex items-center gap-2 mb-2">
420
+ <Upload className="w-5 h-5 text-purple-400" />
421
+ <h3 className="text-lg font-semibold text-white">Клонировать свой голос</h3>
422
+ <span className="px-2 py-0.5 rounded-full bg-purple-500/20 text-purple-300 text-xs font-medium">
423
+ Скоро
424
+ </span>
425
+ </div>
426
+ <p className="text-zinc-400 text-sm mb-4">
427
+ Загрузите аудио 10-30 секунд чётной речи — AI будет говорить вашим голосом
428
  </p>
429
 
430
  {settings.voice_reference_url ? (
 
450
  accept="audio/*"
451
  onChange={handleFileUpload}
452
  className="hidden"
453
+ disabled={uploading || !isServiceAvailable}
454
  />
455
  <div className={cn(
456
+ "flex flex-col items-center justify-center p-8 border-2 border-dashed rounded-xl transition-colors",
457
+ !isServiceAvailable
458
+ ? "border-zinc-700 bg-zinc-800/20 cursor-not-allowed opacity-50"
459
+ : uploading
460
+ ? "border-zinc-600 bg-zinc-800/30 cursor-wait"
461
+ : "border-zinc-700 hover:border-purple-500 hover:bg-purple-500/5 cursor-pointer"
462
  )}>
463
  {uploading ? (
464
+ <Loader2 className="w-8 h-8 animate-spin text-purple-400 mb-2" />
465
  ) : (
466
+ <Upload className="w-8 h-8 text-zinc-500 mb-2" />
467
  )}
468
  <p className="text-white font-medium">
469
+ {!isServiceAvailable
470
+ ? 'Сначала подключите голосовой сервис'
471
+ : uploading
472
+ ? 'Загрузка...'
473
+ : 'Нажмите для загрузки аудио'
474
+ }
475
  </p>
476
  <p className="text-sm text-zinc-500 mt-1">
477
  WAV, MP3, OGG • Максимум 10MB
 
481
  )}
482
  </motion.div>
483
 
484
+ {/* When AI uses voice - Info box */}
485
  <motion.div
486
  initial={{ opacity: 0, y: 20 }}
487
  animate={{ opacity: 1, y: 0 }}
488
  transition={{ delay: 0.3 }}
489
+ className="bg-gradient-to-br from-indigo-500/10 via-purple-500/10 to-pink-500/10 rounded-2xl border border-indigo-500/20 p-6"
490
  >
491
+ <h3 className="text-lg font-semibold text-white mb-4 flex items-center gap-2">
492
+ <Info className="w-5 h-5 text-indigo-400" />
493
+ Когда AI отправляет голосовые?
494
  </h3>
495
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
496
+ {[
497
+ { emoji: '🎙️', text: 'Когда клиент отправляет голосовое (voice-to-voice)' },
498
+ { emoji: '🤝', text: 'При закрытии сделки — для усиления эффекта' },
499
+ { emoji: '💪', text: 'При преодолении возражений — показывает уверенность' },
500
+ { emoji: '❤️', text: 'Для создания доверия ("Я лично гарантирую...")' }
501
+ ].map((item, i) => (
502
+ <div key={i} className="flex items-center gap-3 p-3 rounded-xl bg-white/5">
503
+ <span className="text-xl">{item.emoji}</span>
504
+ <span className="text-zinc-300 text-sm">{item.text}</span>
505
+ </div>
506
+ ))}
507
+ </div>
 
 
 
 
 
508
  </motion.div>
509
  </div>
510
  )