Skip to content

Commit

Permalink
feat: update voices
Browse files Browse the repository at this point in the history
  • Loading branch information
ex3ndr committed Jul 14, 2024
1 parent d1e6c49 commit 7bed681
Show file tree
Hide file tree
Showing 22 changed files with 216 additions and 222 deletions.
103 changes: 103 additions & 0 deletions eval.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions generate_voices.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
model = Supervoice(None, None, encodec_model, None, tokenizer)

# Find all wav files in the voices directory
wav_files = list(Path('voices').glob('*.wav'))
wav_files = list(Path('voices').glob('*.flac'))
wav_files = [f.stem for f in wav_files]

# Generate voices
for id in wav_files:
print(f"Processing {id}")
with open("./voices/" + id + ".txt", 'r') as f:
text = f.read().strip()
created_voice = model.create_voice(audio = "./voices/" + id + ".wav", text = text)
created_voice = model.create_voice(audio = "./voices/" + id + ".flac", text = text)
torch.save(created_voice, f"./voices/{id}.pt")

# Generate index file
Expand Down
10 changes: 2 additions & 8 deletions supervoice_valle/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,17 @@ def create_voice(self, audio, text):

# Prepare text
text = self._normalize_text(text)

# Tokenize text
text_tokens = self.tokenizer.encode(text)

# Return
return {
"audio_tokens": audio_tokens,
"text_tokens": text_tokens,
"text": text,
}

@torch.inference_mode()
def synthesize(self, voice, text, top_k = None, top_p = 0.2):
device = self._device()

# Prepare text
text = self._normalize_text(text)

# Prepare voice
if type(voice) is str:

Expand All @@ -73,7 +67,7 @@ def synthesize(self, voice, text, top_k = None, top_p = 0.2):
voice = torch.load(voice_file, map_location = "cpu")

# Tokenize text
text_tokens = torch.cat([voice["text_tokens"].to(device), self.tokenizer.encode(text).to(device)])
text_tokens = self.tokenizer.encode(self._normalize_text(voice["text"]) + " " + self._normalize_text(text)).to(device)

# Audio tokens
audio_tokens = voice["audio_tokens"].to(device)
Expand Down
2 changes: 1 addition & 1 deletion supervoice_valle/voices_gen.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
available_voices = ['voice_3', 'voice_1', 'voice_2']
available_voices = ['emo_2', 'voice_1', 'emo_1', 'voice_2']
Binary file added voices/emo_1.flac
Binary file not shown.
Binary file added voices/emo_1.pt
Binary file not shown.
1 change: 1 addition & 0 deletions voices/emo_1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ok, but one word!
Binary file added voices/emo_2.flac
Binary file not shown.
Binary file added voices/emo_2.pt
Binary file not shown.
1 change: 1 addition & 0 deletions voices/emo_2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
They are the most beautiful a whole court!
Binary file added voices/voice_1.flac
Binary file not shown.
Binary file modified voices/voice_1.pt
Binary file not shown.
2 changes: 1 addition & 1 deletion voices/voice_1.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
We had not stopped to study the Indian character.
No will powerful enougth to find a way to carry out my wishes.
Binary file removed voices/voice_1.wav
Binary file not shown.
Binary file added voices/voice_2.flac
Binary file not shown.
Binary file modified voices/voice_2.pt
Binary file not shown.
2 changes: 1 addition & 1 deletion voices/voice_2.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
A man approached through the heavy gloom.
And even if both of them has survived the terror.
Binary file removed voices/voice_2.wav
Binary file not shown.
Binary file removed voices/voice_3.pt
Binary file not shown.
1 change: 0 additions & 1 deletion voices/voice_3.txt

This file was deleted.

Binary file removed voices/voice_3.wav
Binary file not shown.
312 changes: 104 additions & 208 deletions welcome.ipynb

Large diffs are not rendered by default.

0 comments on commit 7bed681

Please sign in to comment.