File size: 2,565 Bytes
25647ae
 
 
 
79eafc9
 
 
 
 
 
 
 
25647ae
 
 
 
 
 
 
 
79eafc9
25647ae
 
 
 
79eafc9
 
 
 
 
 
 
8d9b8a5
79eafc9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25647ae
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import React from 'react'
import { Label } from '@/components/ui/label'
import { Input } from '@/components/ui/input'
import { useTextToSpeech } from '../../contexts/TextToSpeechContext'
import { useModel } from '@/contexts/ModelContext'
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue
} from '../ui/select'

interface TextToSpeechConfigProps {
  className?: string
}

const TextToSpeechConfig: React.FC<TextToSpeechConfigProps> = ({
  className = ''
}) => {
  const { modelInfo } = useModel()
  const { config, setConfig } = useTextToSpeech()

  return (
    <div className={`space-y-4 ${className}`}>
      {modelInfo?.isStyleTTS2 ? (
        <div className="space-y-2 h-1/3">
          <p className="text-xs text-gray-500">Style TTS2 Model</p>
          <Label htmlFor="speakerEmbeddings" className="text-sm font-medium">
            Select Voice
          </Label>
          <Select
            value={config.voice || ''}
            onValueChange={(value) =>
              setConfig((prev) => ({
                ...prev,
                voice: value
              }))
            }
          >
            <SelectTrigger className="w-full text-sm xl:text-base">
              <SelectValue placeholder="Select a voice" />
            </SelectTrigger>
            <SelectContent className="max-h-96">
              {modelInfo.voices.map((voice) => (
                <SelectItem key={voice} value={voice} className="text-sm">
                  {voice}
                </SelectItem>
              ))}
            </SelectContent>
          </Select>
          <p className="text-xs text-gray-500">
            Voice to use for text-to-speech synthesis.
          </p>
        </div>
      ) : (
        <div className="space-y-2">
          <Label htmlFor="speakerEmbeddings" className="text-sm font-medium">
            Speaker Embeddings URL
          </Label>
          <Input
            id="speakerEmbeddings"
            type="url"
            value={config.speakerEmbeddings}
            onChange={(e) =>
              setConfig((prev) => ({
                ...prev,
                speakerEmbeddings: e.target.value
              }))
            }
            placeholder="https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/speaker_embeddings.bin"
            className="text-sm"
          />
          <p className="text-xs text-gray-500">
            URL to speaker embeddings file for voice characteristics
          </p>
        </div>
      )}
    </div>
  )
}

export default TextToSpeechConfig