Simonlob commited on
Commit
eed7580
·
1 Parent(s): 589b079

generate sp embedding

Browse files
Files changed (6) hide show
  1. .DS_Store +0 -0
  2. CLAUDE.md +0 -96
  3. app.py +82 -13
  4. examples.yaml +1 -1
  5. make_speaker.py +0 -934
  6. util.py +124 -3
.DS_Store CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
 
CLAUDE.md DELETED
@@ -1,96 +0,0 @@
1
- # CLAUDE.md
2
-
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
-
5
- ## Project Overview
6
-
7
- KaniTTS-2 is a Gradio-based web application for text-to-speech generation using the KaniTTS model family from PyPI. It's designed to run on HuggingFace Spaces with GPU acceleration via the `@spaces.GPU` decorator.
8
-
9
- ## Running the Application
10
-
11
- ```bash
12
- python app.py
13
- ```
14
-
15
- The app launches on `0.0.0.0:7860` with a Gradio interface.
16
-
17
- ## Architecture
18
-
19
- ### Initialization Flow
20
-
21
- The application follows a strict initialization sequence that must be maintained:
22
-
23
- 1. **Dependency Setup** ([app.py:1-3](app.py#L1-L3)): `create_env.setup_dependencies()` runs first to install the dev version of transformers from GitHub. This uses a `/tmp/deps_installed` marker to prevent repeated installations.
24
-
25
- 2. **Configuration Loading** ([app.py:12-13](app.py#L12-L13)): Loads `model_config.yaml` which defines multiple model checkpoints (e.g., "test-135000", "test-130000") with their HuggingFace paths and parameters.
26
-
27
- 3. **Examples Loading** ([app.py:15-17](app.py#L15-L17)): Loads `examples.yaml` via the `Examples` adapter class, which transforms YAML examples into Gradio-compatible list-of-lists format.
28
-
29
- 4. **Model Initialization** ([app.py:19-20](app.py#L19-L20)): `InitModels` loads all models upfront so the UI can switch between them without latency. Each model is a `KaniTTS` instance initialized directly with its config using unpacking (`**config`).
30
-
31
- ### Key Components
32
-
33
- **InitModels** ([util.py:24-57](util.py#L24-L57))
34
- - Lazy initializer that constructs a map of `model_name -> KaniTTS`
35
- - Loads all models immediately in `__call__` for zero-switching latency
36
- - Each `KaniTTS` instance is initialized by unpacking its config directly: `KaniTTS(**config)`
37
- - No longer requires `NemoAudioPlayer` or HuggingFace token as these are handled internally by the PyPI package
38
-
39
- **Examples** ([util.py:59-97](util.py#L59-L97))
40
- - Adapter converting YAML examples to Gradio `gr.Examples` rows
41
- - Order must match UI inputs: `[text, model_dropdown, temp, top_p, rp]`
42
- - Centralizes format and defaults so UI input order changes only require updates here and in [app.py](app.py)
43
-
44
- **generate_speech_gpu** ([app.py:22-55](app.py#L22-L55))
45
- - Decorated with `@spaces.GPU` for HuggingFace Spaces GPU allocation
46
- - Calls the model directly: `audio, _ = model(text, temperature=t, top_p=top_p, repetition_penalty=rp)`
47
- - Returns only the audio tuple: `(sample_rate, audio)` - the text output is ignored
48
-
49
- ### Configuration Files
50
-
51
- **model_config.yaml**
52
- - Defines multiple model checkpoints under the `models` key
53
- - Each model specifies: `model_name` (HF repo path), `device_map`, `use_bematts`, `audio_step`, `use_learnable_rope`
54
- - All config parameters are passed directly to `KaniTTS` constructor via unpacking
55
-
56
- **examples.yaml**
57
- - List of example prompts with their generation parameters
58
- - Each example requires: `text`, `model`, and optionally `temperature`, `top_p`, `repetition_penalty`
59
- - Missing parameters fall back to defaults in [util.py:90-92](util.py#L90-L92): temperature=1.0, top_p=0.95, repetition_penalty=1.1
60
-
61
- ### Dependencies
62
-
63
- - **kani-tts==1.0.1**: Core TTS library from PyPI providing `KaniTTS` class with all inference logic
64
- - **gradio>=4.0.0**: UI framework
65
- - **transformers**: Installed from GitHub main branch via [create_env.py](create_env.py) for latest features
66
-
67
- ### Environment Variables
68
-
69
- - `OMP_NUM_THREADS=4`: Set in [create_env.py:6](create_env.py#L6) to limit OpenMP threading
70
-
71
- ## Important Implementation Notes
72
-
73
- ### Model Inference
74
- - The KaniTTS model is called directly as a callable: `audio, text = model(text, temperature=..., top_p=..., repetition_penalty=...)`
75
- - Returns tuple of `(audio, text)` but only audio is used in the UI
76
- - No `max_tokens` parameter - the model handles sequence length internally
77
- - Sample rate is hardcoded to 22050 Hz ([app.py:48](app.py#L48))
78
-
79
- ### Example Caching
80
- - Examples use `cache_examples=True` ([app.py:131](app.py#L131)) to pre-generate audio, speeding up demo interactions
81
- - If you modify generation logic, cached examples may need regeneration
82
-
83
- ### GPU Allocation
84
- - The `@spaces.GPU` decorator is critical for HuggingFace Spaces deployment
85
- - Without it, the app runs on CPU which is significantly slower
86
- - Device selection falls back gracefully: `"cuda" if torch.cuda.is_available() else "cpu"` ([app.py:35](app.py#L35))
87
-
88
- ### Input Order Dependency
89
- - The order of inputs in `gr.Examples` ([app.py:128](app.py#L128)) must exactly match the order in `Examples.__call__` ([util.py:94](util.py#L94))
90
- - Current order: `[text, model_dropdown, temp, top_p, rp]`
91
- - Changing this requires updates in both locations
92
-
93
- ### Removed Features
94
- - **Speaker selection**: No longer supported in the new API
95
- - **Time reporting**: Generation timing is not tracked
96
- - **Max tokens slider**: Sequence length is handled automatically by the model
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py CHANGED
@@ -4,10 +4,9 @@ setup_dependencies()
4
 
5
  import spaces
6
  import gradio as gr
7
- from util import InitModels, load_config, Examples
8
  import numpy as np
9
  import torch
10
- import json
11
 
12
  config = load_config("./model_config.yaml")
13
  models_configs = config.models
@@ -19,13 +18,30 @@ examples = examples_maker()
19
  init_models = InitModels(models_configs)
20
  models = init_models()
21
 
22
- # Load speaker map
23
- with open("./speakers/speaker_map.json", "r") as f:
24
- speaker_map = json.load(f)
25
 
26
 
27
  @spaces.GPU
28
- def generate_speech_gpu(text, model_choice, speaker_choice, t, top_p, rp):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  """
30
  Generate speech from text using the selected model on GPU
31
  """
@@ -42,8 +58,8 @@ def generate_speech_gpu(text, model_choice, speaker_choice, t, top_p, rp):
42
 
43
  selected_model = models[model_choice]
44
 
45
- # Get speaker embedding path
46
- speaker_emb = speaker_map.get(speaker_choice) if speaker_choice else None
47
 
48
  print(f"Generating speech with {model_choice}...")
49
  audio, _ = selected_model(
@@ -76,12 +92,39 @@ with gr.Blocks(title="😻 KaniTTS - Text to Speech", theme=gr.themes.Ocean()) a
76
  label="Selected Model"
77
  )
78
 
 
 
 
 
 
 
 
 
79
  speaker_dropdown = gr.Dropdown(
80
- choices=list(speaker_map.keys()),
81
- value=list(speaker_map.keys())[0],
82
- label="Speaker"
 
83
  )
84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  text_input = gr.Textbox(
86
  label="Text",
87
  placeholder="Enter your text ...",
@@ -112,10 +155,36 @@ with gr.Blocks(title="😻 KaniTTS - Text to Speech", theme=gr.themes.Ocean()) a
112
  type="numpy"
113
  )
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  # GPU generation event
116
  generate_btn.click(
117
  fn=generate_speech_gpu,
118
- inputs=[text_input, model_dropdown, speaker_dropdown, temp, top_p, rp],
119
  outputs=[audio_output]
120
  )
121
 
@@ -125,7 +194,7 @@ with gr.Blocks(title="😻 KaniTTS - Text to Speech", theme=gr.themes.Ocean()) a
125
 
126
  gr.Examples(
127
  examples=examples,
128
- inputs=[text_input, model_dropdown, speaker_dropdown, temp, top_p, rp],
129
  fn=generate_speech_gpu,
130
  outputs=[audio_output],
131
  cache_examples=True,
 
4
 
5
  import spaces
6
  import gradio as gr
7
+ from util import InitModels, load_config, Examples, SpeakerManager
8
  import numpy as np
9
  import torch
 
10
 
11
  config = load_config("./model_config.yaml")
12
  models_configs = config.models
 
18
  init_models = InitModels(models_configs)
19
  models = init_models()
20
 
21
+ # Initialize speaker manager
22
+ speaker_manager = SpeakerManager()
 
23
 
24
 
25
  @spaces.GPU
26
+ def generate_embedding_gpu(audio_data):
27
+ """
28
+ Generate speaker embedding from audio on GPU
29
+ """
30
+ try:
31
+ if audio_data is None:
32
+ return "No audio provided"
33
+
34
+ embedding = speaker_manager.generate_embedding(audio_data)
35
+ print("Embedding generated successfully!")
36
+ return speaker_manager.get_status()
37
+
38
+ except Exception as e:
39
+ print(f"Error generating embedding: {str(e)}")
40
+ return f"Error: {str(e)}"
41
+
42
+
43
+ @spaces.GPU
44
+ def generate_speech_gpu(text, model_choice, mode, speaker_choice, t, top_p, rp):
45
  """
46
  Generate speech from text using the selected model on GPU
47
  """
 
58
 
59
  selected_model = models[model_choice]
60
 
61
+ # Get speaker embedding based on mode
62
+ speaker_emb = speaker_manager.get_speaker_emb(mode, speaker_choice)
63
 
64
  print(f"Generating speech with {model_choice}...")
65
  audio, _ = selected_model(
 
92
  label="Selected Model"
93
  )
94
 
95
+ # Speaker mode selector
96
+ speaker_mode = gr.Radio(
97
+ choices=["select", "generate"],
98
+ value="select",
99
+ label="Speaker Mode"
100
+ )
101
+
102
+ # Speaker selection (visible in "select" mode)
103
  speaker_dropdown = gr.Dropdown(
104
+ choices=speaker_manager.get_speaker_names(),
105
+ value=speaker_manager.get_speaker_names()[0] if speaker_manager.get_speaker_names() else None,
106
+ label="Speaker",
107
+ visible=True
108
  )
109
 
110
+ # Audio upload and embedding generation (visible in "generate" mode)
111
+ with gr.Group(visible=False) as embedding_group:
112
+ audio_input = gr.Audio(
113
+ label="Upload or Record Audio (16kHz recommended)",
114
+ type="numpy",
115
+ sources=["upload", "microphone"]
116
+ )
117
+
118
+ with gr.Row():
119
+ run_embedding_btn = gr.Button("Run Embedding", variant="secondary")
120
+ clean_embedding_btn = gr.Button("Clean", variant="stop")
121
+
122
+ embedding_status = gr.Textbox(
123
+ label="Embedding Status",
124
+ value="No embedding generated",
125
+ interactive=False
126
+ )
127
+
128
  text_input = gr.Textbox(
129
  label="Text",
130
  placeholder="Enter your text ...",
 
155
  type="numpy"
156
  )
157
 
158
+ # Toggle visibility based on speaker mode
159
+ def toggle_speaker_mode(mode):
160
+ if mode == "select":
161
+ return gr.update(visible=True), gr.update(visible=False)
162
+ else: # generate
163
+ return gr.update(visible=False), gr.update(visible=True)
164
+
165
+ speaker_mode.change(
166
+ fn=toggle_speaker_mode,
167
+ inputs=[speaker_mode],
168
+ outputs=[speaker_dropdown, embedding_group]
169
+ )
170
+
171
+ # Embedding generation events
172
+ run_embedding_btn.click(
173
+ fn=generate_embedding_gpu,
174
+ inputs=[audio_input],
175
+ outputs=[embedding_status]
176
+ )
177
+
178
+ clean_embedding_btn.click(
179
+ fn=speaker_manager.clean,
180
+ inputs=[],
181
+ outputs=[embedding_status]
182
+ )
183
+
184
  # GPU generation event
185
  generate_btn.click(
186
  fn=generate_speech_gpu,
187
+ inputs=[text_input, model_dropdown, speaker_mode, speaker_dropdown, temp, top_p, rp],
188
  outputs=[audio_output]
189
  )
190
 
 
194
 
195
  gr.Examples(
196
  examples=examples,
197
+ inputs=[text_input, model_dropdown, speaker_mode, speaker_dropdown, temp, top_p, rp],
198
  fn=generate_speech_gpu,
199
  outputs=[audio_output],
200
  cache_examples=True,
examples.yaml CHANGED
@@ -16,7 +16,7 @@ examples:
16
  repetition_penalty: 1.1
17
 
18
  - text: >-
19
- Have some wine, the March Hare said in an encouraging tone. Alice looked all round the table, but there was nothing on it but tea. I don't see any wine, she remarked. There isn't any, said the March Hare. Then it wasn't very civil of you to offer it, said Alice angrily. It wasn't very civil of you to sit down without being invited, said the March Hare. I didn't know it was YOUR table, said Alice; it's laid for a great many more than three. Your hair wants cutting, said the Hatter. He had been looking at Alice for some time with great curiosity, and this was his first speech. You should learn not to make personal remarks, Alice said with some severity; it's very rude.
20
  model: "Exp-1"
21
  speaker: "Andrew (en)"
22
  temperature: 1
 
16
  repetition_penalty: 1.1
17
 
18
  - text: >-
19
+ Have some wine, the March Hare said in an encouraging tone. Alice looked all round the table, but there was nothing on it but tea. I don't see any wine, she remarked. There isn't any, said the March Hare. Then it wasn't very civil of you to offer it, said Alice angrily. It wasn't very civil of you to sit down without being invited, said the March Hare. I didn't know it was YOUR table, said Alice; it's laid for a great many more than three. Your hair wants cutting, said the Hatter.
20
  model: "Exp-1"
21
  speaker: "Andrew (en)"
22
  temperature: 1
make_speaker.py DELETED
@@ -1,934 +0,0 @@
1
- import torch
2
-
3
-
4
- sp1 = [
5
- -0.056959059089422226,
6
- -0.07431771606206894,
7
- -0.0007744207978248596,
8
- 0.14234879612922668,
9
- -0.07791736721992493,
10
- 0.044718775898218155,
11
- -0.0025952402502298355,
12
- -0.07470317929983139,
13
- -0.07941192388534546,
14
- -0.06825936585664749,
15
- -0.07658017426729202,
16
- 0.10334887355566025,
17
- 0.1488780379295349,
18
- 0.05303303524851799,
19
- 0.03563545644283295,
20
- 0.006154931616038084,
21
- -0.019980307668447495,
22
- 0.006242025177925825,
23
- -0.07650502771139145,
24
- 0.011423020623624325,
25
- -0.0828247144818306,
26
- 0.09208501130342484,
27
- 0.11241830140352249,
28
- 0.18787875771522522,
29
- -0.05311708152294159,
30
- 0.00862691830843687,
31
- -0.07777128368616104,
32
- 0.21713057160377502,
33
- 0.06223568692803383,
34
- -0.07252423465251923,
35
- -0.08889792859554291,
36
- -0.07656295597553253,
37
- -0.005845929961651564,
38
- 0.037021245807409286,
39
- 0.0019470887491479516,
40
- 0.03835201635956764,
41
- 0.09467420727014542,
42
- -0.09536144882440567,
43
- 0.1606171429157257,
44
- 0.04815187677741051,
45
- -0.0461551658809185,
46
- -0.10729880630970001,
47
- -0.0836249515414238,
48
- -0.014936363324522972,
49
- -0.07798093557357788,
50
- -0.04525156319141388,
51
- -0.02704687789082527,
52
- 0.031187091022729874,
53
- -0.08094345778226852,
54
- 0.03038698248565197,
55
- -0.07573038339614868,
56
- -0.04615750536322594,
57
- 0.03339000046253204,
58
- 0.012611067853868008,
59
- -0.040278010070323944,
60
- -0.05864224582910538,
61
- -0.07855084538459778,
62
- -0.01116874534636736,
63
- -0.07860837131738663,
64
- 0.022938184440135956,
65
- -0.0490887314081192,
66
- 0.012859633192420006,
67
- 0.05778036639094353,
68
- -0.07337072491645813,
69
- 0.033186428248882294,
70
- 0.038420047610998154,
71
- -0.051903847604990005,
72
- 0.18860727548599243,
73
- -0.08550824970006943,
74
- 0.09781505167484283,
75
- -0.050179820507764816,
76
- -0.09151201695203781,
77
- 0.06224966049194336,
78
- -0.07560431957244873,
79
- 0.03041389212012291,
80
- -0.08223845064640045,
81
- -0.07560642808675766,
82
- -0.07574097812175751,
83
- -0.07378879189491272,
84
- 0.09276977181434631,
85
- -0.0721750557422638,
86
- -0.019931843504309654,
87
- -0.016255822032690048,
88
- -0.08486099541187286,
89
- 0.015946706756949425,
90
- 0.219291090965271,
91
- -0.003677315777167678,
92
- 0.03579730913043022,
93
- -0.06582938879728317,
94
- -0.07598833739757538,
95
- -0.0017783945659175515,
96
- -0.07621932774782181,
97
- 0.14186978340148926,
98
- -0.08100845664739609,
99
- -0.016534771770238876,
100
- -0.039146170020103455,
101
- -0.08936012536287308,
102
- -0.0884183868765831,
103
- 0.0818035677075386,
104
- -0.08333006501197815,
105
- -0.08697599172592163,
106
- 0.08900929987430573,
107
- 0.1540442854166031,
108
- 0.06929890811443329,
109
- 0.023458357900381088,
110
- 0.11819791793823242,
111
- 0.05528293922543526,
112
- -0.07724623382091522,
113
- -0.08985307067632675,
114
- -0.07698521018028259,
115
- -0.08518560975790024,
116
- -0.03854784741997719,
117
- 0.05612029507756233,
118
- 0.19019906222820282,
119
- -0.0532655343413353,
120
- 0.10331130772829056,
121
- 0.08962190896272659,
122
- 0.07186102122068405,
123
- -0.08073300868272781,
124
- -0.03013928048312664,
125
- -0.017707977443933487,
126
- 0.061603646725416183,
127
- 0.08824963122606277,
128
- -0.040111809968948364,
129
- -0.04101881384849548,
130
- -0.023703360930085182,
131
- 0.16742625832557678,
132
- -0.08780555427074432
133
- ]
134
-
135
- sp2 = [
136
- -0.050281789153814316,
137
- 0.023217787966132164,
138
- 0.043346893042325974,
139
- -0.043094731867313385,
140
- -0.04279769957065582,
141
- 0.019955242052674294,
142
- -0.07015533745288849,
143
- -0.0764705017209053,
144
- 0.052317824214696884,
145
- -0.08275781571865082,
146
- 0.1702217310667038,
147
- -0.0029036293271929026,
148
- 0.16897068917751312,
149
- -0.033592864871025085,
150
- 0.17897063493728638,
151
- -0.07369279116392136,
152
- -0.08292099088430405,
153
- -0.07833810150623322,
154
- -0.07124188542366028,
155
- 0.09324893355369568,
156
- -0.08365192264318466,
157
- -0.039345383644104004,
158
- 0.13911734521389008,
159
- -0.021355967968702316,
160
- -0.06709616631269455,
161
- -0.0733819454908371,
162
- 0.00957417581230402,
163
- -0.07639335095882416,
164
- -0.042981404811143875,
165
- -0.062470581382513046,
166
- -0.08963305503129959,
167
- 0.052217237651348114,
168
- 0.009040125645697117,
169
- -0.07530245929956436,
170
- 0.07278499752283096,
171
- -0.09641268104314804,
172
- 0.11474557220935822,
173
- -0.09885910898447037,
174
- 0.061111241579055786,
175
- -0.08349886536598206,
176
- -0.03521011769771576,
177
- -0.1121467873454094,
178
- -0.06835179030895233,
179
- -0.04818527400493622,
180
- -0.08024188131093979,
181
- 0.09246063232421875,
182
- -0.0786546915769577,
183
- -0.0678088366985321,
184
- 0.12170662730932236,
185
- 0.006078201346099377,
186
- -0.07792742550373077,
187
- -0.023563995957374573,
188
- -0.07990031689405441,
189
- -0.08500851690769196,
190
- 0.017435764893889427,
191
- -0.008875912986695766,
192
- -0.01564612425863743,
193
- 0.12621375918388367,
194
- -0.05536468327045441,
195
- -0.08361390978097916,
196
- 0.15475153923034668,
197
- -0.0753680020570755,
198
- 0.025031298398971558,
199
- -0.07504384219646454,
200
- 0.11817727982997894,
201
- 0.22630754113197327,
202
- 0.1351470947265625,
203
- 0.14117325842380524,
204
- -0.07466709613800049,
205
- -0.017258374020457268,
206
- -0.058375779539346695,
207
- -0.09002719074487686,
208
- 0.1529882848262787,
209
- 0.054032210260629654,
210
- -0.07923610508441925,
211
- 0.04768155887722969,
212
- 0.013129397295415401,
213
- -0.07510846108198166,
214
- -0.07405361533164978,
215
- -0.06735733896493912,
216
- 0.07549432665109634,
217
- -0.07524596899747849,
218
- 0.023765340447425842,
219
- -0.04690846800804138,
220
- -0.0456087701022625,
221
- 0.013412008062005043,
222
- -0.07029068470001221,
223
- -0.09484000504016876,
224
- 0.008935618214309216,
225
- 0.14847226440906525,
226
- 0.10177381336688995,
227
- -0.0767863541841507,
228
- 0.20601123571395874,
229
- -0.07636284828186035,
230
- -0.07587302476167679,
231
- -0.0172903873026371,
232
- 0.031998757272958755,
233
- -0.024688469246029854,
234
- -0.08434971421957016,
235
- -0.08759179711341858,
236
- 0.02792895957827568,
237
- 0.0656527578830719,
238
- 0.05782775953412056,
239
- 0.09333281219005585,
240
- -0.06884845346212387,
241
- -0.07939416170120239,
242
- 0.15371105074882507,
243
- -0.026411522179841995,
244
- 0.07004162669181824,
245
- -0.07803111523389816,
246
- -0.0015616194577887654,
247
- 0.10434804111719131,
248
- -0.008118604309856892,
249
- 0.06711513549089432,
250
- -0.035488326102495193,
251
- -0.066922128200531,
252
- -0.06753159314393997,
253
- -0.08739693462848663,
254
- -0.06943987309932709,
255
- -0.0800175592303276,
256
- -0.07267877459526062,
257
- -0.0846465677022934,
258
- 0.05650201067328453,
259
- -0.0858917236328125,
260
- 0.11707165837287903,
261
- -0.07632513344287872,
262
- -0.07149224728345871,
263
- 0.0010398230515420437
264
- ]
265
-
266
- sp3 = [
267
- 0.044863346964120865,
268
- -0.08795837312936783,
269
- 0.00623549846932292,
270
- -0.041037190705537796,
271
- 0.15892581641674042,
272
- 0.06204115226864815,
273
- -0.07757825404405594,
274
- 0.12236713618040085,
275
- 0.004264748655259609,
276
- -0.09987714886665344,
277
- 0.05126308649778366,
278
- 0.037995338439941406,
279
- -0.08919689059257507,
280
- 0.04392874240875244,
281
- -0.09021709114313126,
282
- -0.0738280862569809,
283
- 0.02076968550682068,
284
- 0.1070074662566185,
285
- 0.049832168966531754,
286
- 0.17484578490257263,
287
- -0.013567082583904266,
288
- 0.10016804933547974,
289
- -0.08356668800115585,
290
- 0.0636911690235138,
291
- -0.009811697527766228,
292
- -0.07636874169111252,
293
- -0.06126904860138893,
294
- -0.053117018193006516,
295
- 0.01112096942961216,
296
- 0.011951063759624958,
297
- 0.11347390711307526,
298
- 0.07987657189369202,
299
- 0.09502555429935455,
300
- 0.045208342373371124,
301
- -0.047236792743206024,
302
- -0.07695288211107254,
303
- -0.00397157296538353,
304
- 0.2076280117034912,
305
- -0.08805114775896072,
306
- -0.06516429036855698,
307
- 0.0346195288002491,
308
- -0.007755806669592857,
309
- 0.12718522548675537,
310
- -0.04961549863219261,
311
- -0.08501579612493515,
312
- -0.08136767894029617,
313
- -0.015555771067738533,
314
- -0.0896003246307373,
315
- 0.008332539349794388,
316
- -0.08981787413358688,
317
- 0.12871037423610687,
318
- -0.08342160284519196,
319
- -0.06250006705522537,
320
- -0.0906406119465828,
321
- 0.0739695206284523,
322
- -0.07614704221487045,
323
- 0.0028914636932313442,
324
- -0.06738509982824326,
325
- -0.0908239558339119,
326
- -0.004341233056038618,
327
- -0.08561462163925171,
328
- -0.06059376150369644,
329
- -0.08309012651443481,
330
- 0.02291426807641983,
331
- -0.08814181387424469,
332
- -0.07243850082159042,
333
- -0.10541810095310211,
334
- -0.006142698228359222,
335
- 0.03829303756356239,
336
- -0.08143717795610428,
337
- -0.052729811519384384,
338
- -0.08436775207519531,
339
- -0.0825762078166008,
340
- -0.023270217701792717,
341
- -0.09676963090896606,
342
- 0.18764223158359528,
343
- -0.0035655321553349495,
344
- 0.060881830751895905,
345
- 0.019288599491119385,
346
- -0.0646059513092041,
347
- 0.2043074071407318,
348
- -0.052328258752822876,
349
- -0.08275464177131653,
350
- 0.006811313796788454,
351
- -0.09141694009304047,
352
- -0.0643858015537262,
353
- -0.04983310401439667,
354
- 0.022007863968610764,
355
- 0.0523625947535038,
356
- 0.12141022831201553,
357
- -0.09637351334095001,
358
- 0.09305799007415771,
359
- -0.08631274104118347,
360
- -0.08203761279582977,
361
- 0.01890491507947445,
362
- -0.09548700600862503,
363
- 0.06787174195051193,
364
- 0.0185020100325346,
365
- 0.13169577717781067,
366
- -0.07152362912893295,
367
- 0.08089947700500488,
368
- 0.0007502693333663046,
369
- -0.04203244671225548,
370
- -0.09299170970916748,
371
- -0.06988460570573807,
372
- -0.07600069046020508,
373
- 0.016998400911688805,
374
- 0.11065729707479477,
375
- 0.1770820915699005,
376
- -0.07554581016302109,
377
- 0.14596983790397644,
378
- -0.06950408965349197,
379
- -0.08761636167764664,
380
- 0.05795743688941002,
381
- -0.09482874721288681,
382
- -0.07928589731454849,
383
- -0.07619829475879669,
384
- 0.026845542713999748,
385
- -0.08625771850347519,
386
- -0.08191405981779099,
387
- -0.033759284764528275,
388
- -0.09005032479763031,
389
- -0.09133398532867432,
390
- 0.13270556926727295,
391
- -0.03323248401284218,
392
- -0.06472556293010712,
393
- -0.07661902159452438,
394
- -0.0922679528594017
395
- ]
396
-
397
-
398
- sp4 = [
399
- 0.014975552447140217,
400
- 0.1201590821146965,
401
- -0.04833684489130974,
402
- -0.042657576501369476,
403
- -0.07680147886276245,
404
- 0.008444481529295444,
405
- 0.04672827199101448,
406
- 0.0655755028128624,
407
- 0.11940808594226837,
408
- -0.07818085700273514,
409
- -0.07619981467723846,
410
- -0.034715279936790466,
411
- -0.08239906281232834,
412
- 0.02117394655942917,
413
- 0.026922911405563354,
414
- -0.02619064413011074,
415
- -0.08279731124639511,
416
- -0.08409284800291061,
417
- -0.07563990354537964,
418
- -0.07746758311986923,
419
- 0.017148327082395554,
420
- 0.07626708596944809,
421
- 0.07004616409540176,
422
- 0.03208186477422714,
423
- -0.03150057792663574,
424
- 0.11792197823524475,
425
- -0.07686424255371094,
426
- 0.004818132147192955,
427
- -0.09032411873340607,
428
- -0.08447712659835815,
429
- 0.020521923899650574,
430
- -0.058463796973228455,
431
- -0.07045496255159378,
432
- 0.0969952866435051,
433
- -0.0420924574136734,
434
- -0.02713640220463276,
435
- -0.08808104693889618,
436
- 0.0425461009144783,
437
- 0.04754403978586197,
438
- -0.0019016547594219446,
439
- -0.04388159513473511,
440
- 0.025083905085921288,
441
- -0.08270448446273804,
442
- -0.0770757868885994,
443
- 0.09254211187362671,
444
- 0.10774955153465271,
445
- -0.06317340582609177,
446
- -0.07892616838216782,
447
- -0.08005274832248688,
448
- 0.04106053337454796,
449
- 0.0981193482875824,
450
- 0.032208967953920364,
451
- 0.032562531530857086,
452
- -0.040666233748197556,
453
- -0.09163665026426315,
454
- 0.14852704107761383,
455
- -0.07776651531457901,
456
- 0.09260601550340652,
457
- -0.08714006841182709,
458
- 0.02349991351366043,
459
- 0.09777960926294327,
460
- 0.012837720103561878,
461
- -0.0681685283780098,
462
- 0.09760434180498123,
463
- 0.11893817782402039,
464
- -0.06687002629041672,
465
- 0.10464373975992203,
466
- -0.07898904383182526,
467
- 0.03718216344714165,
468
- -0.001790654263459146,
469
- 0.1210879310965538,
470
- 0.09112358093261719,
471
- 0.07040399312973022,
472
- -0.021451229229569435,
473
- -0.016307493671774864,
474
- 0.11010289192199707,
475
- 0.19557251036167145,
476
- -0.06409434229135513,
477
- -0.07242149859666824,
478
- 0.0815720334649086,
479
- -0.0742398202419281,
480
- 0.15758396685123444,
481
- 0.0034991512075066566,
482
- -0.08164040744304657,
483
- 0.09242386370897293,
484
- -0.07533959299325943,
485
- 0.12539155781269073,
486
- 0.034026630222797394,
487
- -0.07615572959184647,
488
- -0.07524855434894562,
489
- -0.0046832324005663395,
490
- 0.02044426091015339,
491
- -0.07627419382333755,
492
- 0.0906405821442604,
493
- 0.15664952993392944,
494
- 0.014610418118536472,
495
- -0.06705746054649353,
496
- 0.12825961410999298,
497
- 0.06035701185464859,
498
- 0.17567360401153564,
499
- -0.0796094685792923,
500
- -0.07080274820327759,
501
- -0.08287626504898071,
502
- -0.06109911575913429,
503
- -0.022632954642176628,
504
- -0.07906034588813782,
505
- -0.0585855208337307,
506
- -0.07637544721364975,
507
- -0.08893950283527374,
508
- 0.08905342221260071,
509
- 0.06906967610120773,
510
- 0.07786651700735092,
511
- -0.03081165812909603,
512
- -0.10391682386398315,
513
- -0.009698718786239624,
514
- 0.09618605673313141,
515
- 0.1353370100259781,
516
- -0.009754122234880924,
517
- -0.0798230841755867,
518
- 0.14158795773983002,
519
- 0.07175704091787338,
520
- 0.009440293535590172,
521
- -0.08403725177049637,
522
- -0.010469981469213963,
523
- -0.09179911017417908,
524
- 0.012903331778943539,
525
- 0.03833264485001564,
526
- 0.1914415955543518
527
- ]
528
-
529
- sp5 = [
530
- -0.07472408562898636,
531
- 0.2077360600233078,
532
- -0.057473067194223404,
533
- -0.07846137136220932,
534
- 0.0486067496240139,
535
- -0.09742959588766098,
536
- 0.012818996794521809,
537
- -0.04314102977514267,
538
- -0.07742120325565338,
539
- -0.012238459661602974,
540
- 0.16626425087451935,
541
- -0.06014818325638771,
542
- 0.030748408287763596,
543
- -0.07885394245386124,
544
- 0.08880891650915146,
545
- 0.04357529431581497,
546
- -0.08909814804792404,
547
- -0.08589012920856476,
548
- 0.017018966376781464,
549
- -0.06919971853494644,
550
- -0.0647362470626831,
551
- -0.06408999860286713,
552
- -0.06747046113014221,
553
- -0.08739134669303894,
554
- -0.06523431837558746,
555
- -0.07173540443181992,
556
- -0.07459395378828049,
557
- -0.07758451998233795,
558
- -0.09113436937332153,
559
- 0.02833479642868042,
560
- 0.010935867205262184,
561
- -0.04095727205276489,
562
- -0.008447790518403053,
563
- -0.015916690230369568,
564
- -0.06783552467823029,
565
- 0.16540202498435974,
566
- 0.08896030485630035,
567
- -0.022869249805808067,
568
- -0.08067937195301056,
569
- -0.07047552615404129,
570
- -0.0791078507900238,
571
- -0.11707916855812073,
572
- -0.08358949422836304,
573
- -0.08547090739011765,
574
- -0.0013615615898743272,
575
- -0.08036443591117859,
576
- -0.04231594502925873,
577
- -0.0837881937623024,
578
- -0.02109750732779503,
579
- 0.06521718949079514,
580
- 0.03358446806669235,
581
- 0.1431589126586914,
582
- -0.027682557702064514,
583
- 0.03217494115233421,
584
- -0.06871805340051651,
585
- -0.06577359139919281,
586
- 0.10372865945100784,
587
- -0.05901371315121651,
588
- 0.0447809062898159,
589
- -0.07911419868469238,
590
- 0.2223190814256668,
591
- 0.033684857189655304,
592
- -0.01980946958065033,
593
- -0.009113002568483353,
594
- 0.061996620148420334,
595
- -0.06760461628437042,
596
- 0.0793633908033371,
597
- 0.09014952927827835,
598
- 0.06929260492324829,
599
- -0.01617756299674511,
600
- 0.07633700966835022,
601
- 0.016587991267442703,
602
- -0.0069177825935184956,
603
- -0.019375547766685486,
604
- 0.026005519554018974,
605
- -0.0949050784111023,
606
- 0.13627009093761444,
607
- 0.0007139204535633326,
608
- 0.016387799754738808,
609
- -0.07186658680438995,
610
- -0.009011861868202686,
611
- 0.022241994738578796,
612
- 0.06350655108690262,
613
- 0.10589846968650818,
614
- -0.09742557257413864,
615
- -0.06443683803081512,
616
- 0.004297737963497639,
617
- -0.09466835856437683,
618
- 0.04342241585254669,
619
- 0.08106304705142975,
620
- 0.12201986461877823,
621
- 0.04398150369524956,
622
- -0.009540509432554245,
623
- 0.06304764747619629,
624
- -0.08143053948879242,
625
- 0.1555684208869934,
626
- -0.06324099004268646,
627
- 0.04688173905014992,
628
- -0.08392588794231415,
629
- 0.19633686542510986,
630
- 0.08215086907148361,
631
- -0.07445380836725235,
632
- 0.05648314580321312,
633
- -0.07521350681781769,
634
- -0.08106789737939835,
635
- -0.0769851952791214,
636
- -0.09946925938129425,
637
- 0.07573969662189484,
638
- -0.008974740281701088,
639
- -0.0393686518073082,
640
- -0.0017469975864514709,
641
- -0.08926048129796982,
642
- -0.04622442275285721,
643
- -0.09214682877063751,
644
- 0.005119341425597668,
645
- 0.10839592665433884,
646
- -0.050333209335803986,
647
- -0.09676054120063782,
648
- 0.047501906752586365,
649
- -0.06837188452482224,
650
- 0.1552308201789856,
651
- 0.02244103141129017,
652
- -0.08457397669553757,
653
- -0.05681031569838524,
654
- 0.015423906035721302,
655
- -0.08144135773181915,
656
- -0.06842615455389023,
657
- -0.03671957924962044
658
- ]
659
-
660
-
661
- sp6 = [
662
- -0.004930280148983002,
663
- 0.08562461286783218,
664
- -0.0764380544424057,
665
- 0.12423505634069443,
666
- 0.06380770355463028,
667
- -0.0833282396197319,
668
- -0.0704629123210907,
669
- -0.02359308861196041,
670
- -0.11950968950986862,
671
- -0.05383031815290451,
672
- 0.13100019097328186,
673
- -0.04609416425228119,
674
- 0.11273174732923508,
675
- -0.0883885845541954,
676
- -0.016859225928783417,
677
- 0.03442854806780815,
678
- -0.1029595360159874,
679
- -0.07559429109096527,
680
- 0.12149295210838318,
681
- 0.014217427931725979,
682
- -0.06553817540407181,
683
- 0.06483729183673859,
684
- -0.0832972452044487,
685
- -0.0895114466547966,
686
- -0.07193689048290253,
687
- -0.0770263597369194,
688
- 0.00022856975556351244,
689
- 0.011081762611865997,
690
- -0.06022211164236069,
691
- -0.07772520184516907,
692
- -0.04475982487201691,
693
- 0.15953606367111206,
694
- -0.08595475554466248,
695
- 0.07281705737113953,
696
- -0.043590039014816284,
697
- 0.024075673893094063,
698
- -0.03666220232844353,
699
- 0.05976352468132973,
700
- -0.00404775096103549,
701
- -0.09037335962057114,
702
- -0.025358861312270164,
703
- -0.08681948482990265,
704
- -0.08855558931827545,
705
- -0.0653468519449234,
706
- 0.05669263005256653,
707
- -0.07210364937782288,
708
- -0.05875953659415245,
709
- -0.09035740792751312,
710
- 0.028884833678603172,
711
- -0.07896765321493149,
712
- 0.02423865534365177,
713
- 0.13390737771987915,
714
- -0.013620391488075256,
715
- -0.02224227413535118,
716
- 0.015568692237138748,
717
- 0.11594505608081818,
718
- 0.11687905341386795,
719
- -0.018582934513688087,
720
- -0.09030970931053162,
721
- 0.005574168637394905,
722
- -0.04361603781580925,
723
- -0.03851548582315445,
724
- -0.08371025323867798,
725
- -0.03500206768512726,
726
- -0.02459687739610672,
727
- -0.07222030311822891,
728
- 0.08121480792760849,
729
- 0.03040383756160736,
730
- -0.03100021556019783,
731
- -0.07651577889919281,
732
- 0.03292612358927727,
733
- 0.026235831901431084,
734
- -0.08650624006986618,
735
- -0.01090069767087698,
736
- 0.03657924383878708,
737
- -0.08384150266647339,
738
- 0.064586341381073,
739
- 0.09112914651632309,
740
- 0.07503412663936615,
741
- -0.07587313652038574,
742
- 0.12387727946043015,
743
- -0.020256295800209045,
744
- 0.040244076400995255,
745
- -0.06343528628349304,
746
- -0.04044422134757042,
747
- 0.02972465194761753,
748
- 0.04687220975756645,
749
- -0.008625105954706669,
750
- 0.1008363887667656,
751
- 0.010900158435106277,
752
- -0.09016355872154236,
753
- 0.04838952794671059,
754
- -0.04105637967586517,
755
- 0.013639458455145359,
756
- -0.07048259675502777,
757
- -0.08235885202884674,
758
- -0.08882340788841248,
759
- -0.09107483923435211,
760
- 0.03668944537639618,
761
- 0.0019158608047291636,
762
- -0.022357558831572533,
763
- 0.1465294361114502,
764
- 0.07629132270812988,
765
- -0.06898661702871323,
766
- -0.08680594712495804,
767
- -0.08412013947963715,
768
- -0.002412576461210847,
769
- 0.1506911963224411,
770
- -0.009846117347478867,
771
- -0.0802307203412056,
772
- 0.020010171458125114,
773
- -0.06089577078819275,
774
- -0.08643854409456253,
775
- -0.1062886118888855,
776
- -0.08187893778085709,
777
- 0.0315963439643383,
778
- -0.07040993869304657,
779
- -0.060491085052490234,
780
- -0.030400332063436508,
781
- 0.13255496323108673,
782
- -0.06075480952858925,
783
- -0.08898318558931351,
784
- -0.08366542309522629,
785
- -0.006396912969648838,
786
- 0.09778483957052231,
787
- 0.05774940177798271,
788
- -0.053698617964982986,
789
- -0.07357174903154373
790
- ]
791
-
792
- sp7 = [
793
- 0.09096527099609375,
794
- 0.12818661332130432,
795
- 0.05300923064351082,
796
- -0.0620405450463295,
797
- -0.07956791669130325,
798
- -0.09087102115154266,
799
- 0.021690314635634422,
800
- 0.0144176771864295,
801
- 0.0019766734912991524,
802
- 0.007868418470025063,
803
- -0.07859831303358078,
804
- -0.060859933495521545,
805
- -0.0775991678237915,
806
- 0.01997179351747036,
807
- 0.15887515246868134,
808
- 0.07313112914562225,
809
- -0.09271703660488129,
810
- -0.08671814203262329,
811
- -0.07813264429569244,
812
- -0.07720690965652466,
813
- -0.07696140557527542,
814
- 0.18065419793128967,
815
- 0.10781082510948181,
816
- -0.022600548341870308,
817
- 0.06215902790427208,
818
- -0.02438243292272091,
819
- -0.07941883057355881,
820
- 0.07533253729343414,
821
- -0.09328891336917877,
822
- -0.05382213741540909,
823
- -0.06141037493944168,
824
- -0.07790078967809677,
825
- 0.1648797243833542,
826
- 0.0423060841858387,
827
- -0.07286743074655533,
828
- 0.04643263295292854,
829
- -0.06554959714412689,
830
- -0.032457154244184494,
831
- 0.09949684888124466,
832
- 0.025956032797694206,
833
- 0.03757084533572197,
834
- 0.025580935180187225,
835
- -0.08542721718549728,
836
- -0.002371697686612606,
837
- -0.018300838768482208,
838
- -0.09333072602748871,
839
- 0.09380193054676056,
840
- -0.08460453152656555,
841
- -0.08267955482006073,
842
- 0.011247556656599045,
843
- 0.06678486615419388,
844
- 0.06353003531694412,
845
- -0.05372804403305054,
846
- -0.04275272786617279,
847
- -0.09475936740636826,
848
- -0.02697761356830597,
849
- -0.08031945675611496,
850
- 0.09705562144517899,
851
- 0.0034417700953781605,
852
- 0.026172643527388573,
853
- 0.15678609907627106,
854
- 0.15548571944236755,
855
- 0.08869600296020508,
856
- 0.0034438855946063995,
857
- 0.04129115864634514,
858
- -0.06807658076286316,
859
- -0.048452526330947876,
860
- 0.00348582467995584,
861
- -0.005682673305273056,
862
- 0.05030336230993271,
863
- 0.024773158133029938,
864
- 0.08784151077270508,
865
- 0.08264995366334915,
866
- 0.07744842767715454,
867
- 0.006688673049211502,
868
- 0.11568285524845123,
869
- -0.0006149086402729154,
870
- -0.07731792330741882,
871
- -0.07520095258951187,
872
- 0.050927311182022095,
873
- -0.07624947279691696,
874
- -0.017263416200876236,
875
- -0.07306291908025742,
876
- -0.04022892937064171,
877
- -0.043212465941905975,
878
- 0.025481276214122772,
879
- 0.009810780175030231,
880
- -0.03424441069364548,
881
- -0.07623236626386642,
882
- -0.07723627239465714,
883
- 0.14873334765434265,
884
- -0.07702631503343582,
885
- 0.013342263177037239,
886
- -0.07819023728370667,
887
- -0.06493690609931946,
888
- 0.007031683810055256,
889
- -0.11437463015317917,
890
- -0.04450619965791702,
891
- -0.0739501342177391,
892
- 0.03370510786771774,
893
- 0.006866330746561289,
894
- 0.04877154901623726,
895
- 0.09061554819345474,
896
- -0.06745804101228714,
897
- 0.03955249860882759,
898
- -0.08013571798801422,
899
- -0.050169579684734344,
900
- -0.07888628542423248,
901
- -0.09185811877250671,
902
- -0.008135518059134483,
903
- -0.032329343259334564,
904
- 0.05627875775098801,
905
- -0.034713007509708405,
906
- 0.03831075131893158,
907
- 0.051426082849502563,
908
- 0.12307145446538925,
909
- 0.13895918428897858,
910
- -0.055210549384355545,
911
- -0.0824555903673172,
912
- -0.046466924250125885,
913
- 0.138591930270195,
914
- -0.06990546733140945,
915
- -0.07223182171583176,
916
- -0.026878757402300835,
917
- 0.12467526644468307,
918
- 0.06654545664787292,
919
- 0.04314073547720909,
920
- 0.0024285614490509033
921
- ]
922
-
923
-
924
- torch.save(torch.tensor(sp1), './speakers/speaker_1.pt') # Kore (en)
925
- torch.save(torch.tensor(sp2), './speakers/speaker_2.pt') # Puck (en)
926
- torch.save(torch.tensor(sp3), './speakers/speaker_3.pt') # Andrew (en)
927
-
928
- torch.save(torch.tensor(sp4), './speakers/speaker_4.pt') # Aisulu (ky)
929
- torch.save(torch.tensor(sp5), './speakers/speaker_5.pt') # Baike (ky)
930
-
931
-
932
- torch.save(torch.tensor(sp6), './speakers/speaker_6.pt') # Ash (es)
933
- torch.save(torch.tensor(sp7), './speakers/speaker_7.pt') # Nova (es)
934
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
util.py CHANGED
@@ -2,6 +2,8 @@ from kani_tts import KaniTTS
2
  from kani_tts import SpeakerEmbedder
3
 
4
  import os
 
 
5
  from omegaconf import OmegaConf
6
 
7
 
@@ -62,6 +64,124 @@ class InitModels:
62
  print("All models loaded!")
63
  return models
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  class Examples:
66
 
67
  """
@@ -77,7 +197,7 @@ class Examples:
77
  --------
78
  - Produces a list-of-lists whose order must match the `inputs` order
79
  used when constructing `gr.Examples` in `app.py`.
80
- - Current order: `[text, model_dropdown, speaker_dropdown, temp, top_p, rp]`.
81
 
82
  Why this exists
83
  ---------------
@@ -93,12 +213,13 @@ class Examples:
93
  for e in self.exam_cfg.examples:
94
  text = e.get("text")
95
  model = e.get("model")
 
96
  speaker = e.get("speaker", "Kore (en)")
97
  temperature = e.get("temperature", 1.0)
98
  top_p = e.get("top_p", 0.95)
99
  repetition_penalty = e.get("repetition_penalty", 1.1)
100
- # Order must match gr.Examples inputs: [text, model_dropdown, speaker_dropdown, temp, top_p, rp]
101
- rows.append([text, model, speaker, temperature, top_p, repetition_penalty])
102
 
103
  return rows
104
 
 
2
  from kani_tts import SpeakerEmbedder
3
 
4
  import os
5
+ import json
6
+ import torch
7
  from omegaconf import OmegaConf
8
 
9
 
 
64
  print("All models loaded!")
65
  return models
66
 
67
+ class SpeakerManager:
68
+ """
69
+ Manages speaker embeddings for the TTS application.
70
+
71
+ Supports two modes:
72
+ 1. Select speaker: Load pre-saved speaker embeddings from speaker_map.json
73
+ 2. Generate embedding: Generate speaker embedding from uploaded audio using SpeakerEmbedder
74
+
75
+ Parameters
76
+ ----------
77
+ speaker_map_path : str
78
+ Path to speaker_map.json file
79
+
80
+ Methods
81
+ -------
82
+ get_speaker_emb(mode, speaker_name=None) -> str | torch.Tensor | None
83
+ Returns speaker embedding based on mode:
84
+ - "select": Returns path to .pt file from speaker_map
85
+ - "generate": Returns cached generated embedding tensor or None
86
+
87
+ generate_embedding(audio_data, sample_rate) -> torch.Tensor
88
+ Generates speaker embedding from audio using SpeakerEmbedder.
89
+ Expects audio at 16kHz. Caches the result internally.
90
+
91
+ clean()
92
+ Clears cached generated embedding.
93
+
94
+ get_speaker_names() -> list[str]
95
+ Returns list of available speaker names from speaker_map.json.
96
+ """
97
+
98
+ def __init__(self, speaker_map_path: str = "./speakers/speaker_map.json"):
99
+ self.speaker_map_path = speaker_map_path
100
+ self.speaker_map = self._load_speaker_map()
101
+ self.cached_embedding = None
102
+ self.embedder = None
103
+
104
+ def _load_speaker_map(self):
105
+ """Load speaker map from JSON file."""
106
+ if not os.path.exists(self.speaker_map_path):
107
+ return {}
108
+ with open(self.speaker_map_path, "r") as f:
109
+ return json.load(f)
110
+
111
+ def get_speaker_names(self):
112
+ """Get list of available speaker names."""
113
+ return list(self.speaker_map.keys())
114
+
115
+ def get_speaker_emb(self, mode: str, speaker_name: str = None):
116
+ """
117
+ Get speaker embedding based on mode.
118
+
119
+ Parameters
120
+ ----------
121
+ mode : str
122
+ Either "select" or "generate"
123
+ speaker_name : str, optional
124
+ Name of speaker from speaker_map (only used in "select" mode)
125
+
126
+ Returns
127
+ -------
128
+ str | torch.Tensor | None
129
+ Path to .pt file (select mode) or embedding tensor (generate mode)
130
+ """
131
+ if mode == "select":
132
+ if speaker_name and speaker_name in self.speaker_map:
133
+ return self.speaker_map[speaker_name]
134
+ return None
135
+ elif mode == "generate":
136
+ return self.cached_embedding
137
+ return None
138
+
139
+ def generate_embedding(self, audio_data, sample_rate: int = 16000):
140
+ """
141
+ Generate speaker embedding from audio data.
142
+
143
+ Parameters
144
+ ----------
145
+ audio_data : tuple | np.ndarray
146
+ Either (sample_rate, audio_array) tuple from Gradio or numpy array
147
+ sample_rate : int
148
+ Sample rate of the audio (default: 16000)
149
+
150
+ Returns
151
+ -------
152
+ torch.Tensor
153
+ Generated speaker embedding [1, 128]
154
+ """
155
+ # Initialize embedder lazily
156
+ if self.embedder is None:
157
+ self.embedder = SpeakerEmbedder()
158
+
159
+ # Handle Gradio audio format (sr, audio) tuple
160
+ if isinstance(audio_data, tuple):
161
+ sample_rate, audio_array = audio_data
162
+ else:
163
+ audio_array = audio_data
164
+
165
+ # Generate embedding
166
+ embedding = self.embedder.embed_audio(audio_array, sample_rate=sample_rate)
167
+
168
+ # Cache the result
169
+ self.cached_embedding = embedding
170
+
171
+ return embedding
172
+
173
+ def clean(self):
174
+ """Clear cached generated embedding."""
175
+ self.cached_embedding = None
176
+ return "Embedding cleared"
177
+
178
+ def get_status(self):
179
+ """Get current status of generated embedding."""
180
+ if self.cached_embedding is not None:
181
+ return "✅ Embedding ready"
182
+ return "No embedding generated"
183
+
184
+
185
  class Examples:
186
 
187
  """
 
197
  --------
198
  - Produces a list-of-lists whose order must match the `inputs` order
199
  used when constructing `gr.Examples` in `app.py`.
200
+ - Current order: `[text, model_dropdown, speaker_mode, speaker_dropdown, temp, top_p, rp]`.
201
 
202
  Why this exists
203
  ---------------
 
213
  for e in self.exam_cfg.examples:
214
  text = e.get("text")
215
  model = e.get("model")
216
+ speaker_mode = e.get("speaker_mode", "select") # Default to "select" mode
217
  speaker = e.get("speaker", "Kore (en)")
218
  temperature = e.get("temperature", 1.0)
219
  top_p = e.get("top_p", 0.95)
220
  repetition_penalty = e.get("repetition_penalty", 1.1)
221
+ # Order must match gr.Examples inputs: [text, model_dropdown, speaker_mode, speaker_dropdown, temp, top_p, rp]
222
+ rows.append([text, model, speaker_mode, speaker, temperature, top_p, repetition_penalty])
223
 
224
  return rows
225