MegaTronX commited on
Commit
0011a8d
Β·
verified Β·
1 Parent(s): 65e6868

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from TTS.api import TTS
2
+ import torch
3
+
4
+ # Initialize TTS
5
+ tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2", gpu=True)
6
+
7
+ # Generate and save speaker embedding
8
+ def save_speaker_embedding(speaker_wav, output_path):
9
+ embedding = tts.speaker_manager.compute_embedding_from_clip(speaker_wav)
10
+ torch.save(embedding, output_path)
11
+ return output_path
12
+
13
+ # Example usage
14
+ speaker_wav = "path/to/speaker_audio.wav"
15
+ output_embedding_path = "speaker_embedding.pth"
16
+ save_speaker_embedding(speaker_wav, output_embedding_path)
17
+ print(f"Speaker embedding saved at {output_embedding_path}")