Compare commits
10 Commits
394a3f26ee
...
abf885acf7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abf885acf7 | ||
|
|
fcfed7670d | ||
|
|
9ce1d62e30 | ||
|
|
7a2a940161 | ||
|
|
d899b53164 | ||
|
|
21b653669f | ||
|
|
0fc8fda70e | ||
|
|
50a8a00039 | ||
|
|
312bead583 | ||
|
|
25d53e77c0 |
@@ -32,6 +32,10 @@ docker build -t melotts .
|
||||
|
||||
**Run Docker**
|
||||
```bash
|
||||
docker run -it -p 8888:8888 melotts
|
||||
```
|
||||
If your local machine has GPU, then you can choose to run:
|
||||
```bash
|
||||
docker run --gpus all -it -p 8888:8888 melotts
|
||||
```
|
||||
Then open [http://localhost:8888](http://localhost:8888) in your browser to use the app.
|
||||
|
||||
20
melo/data/example/metadata.list
Normal file
20
melo/data/example/metadata.list
Normal file
@@ -0,0 +1,20 @@
|
||||
data/example/wavs/000.wav|EN-default|EN|Well, there are always new trends and styles emerging in the fashion world, but I think some of the biggest trends at the moment include sustainability and ethical fashion, streetwear and athleisure, and oversized and deconstructed silhouettes.
|
||||
data/example/wavs/001.wav|EN-default|EN|Many designers and brands are focusing on creating more environmentally-friendly and socially responsible clothing, while others are incorporating elements of sportswear and casual wear into their collections.
|
||||
data/example/wavs/002.wav|EN-default|EN|And there's a growing interest in looser, more relaxed shapes and unconventional materials and finishes.
|
||||
data/example/wavs/003.wav|EN-default|EN|That's really insightful.
|
||||
data/example/wavs/004.wav|EN-default|EN|What do you think are some of the benefits of following fashion trends?
|
||||
data/example/wavs/005.wav|EN-default|EN|Well, I think one of the main benefits of following fashion trends is that it can be a way to express your creativity, personality, and individuality.
|
||||
data/example/wavs/006.wav|EN-default|EN|Fashion can be a powerful tool for self-expression and can help you feel more confident and comfortable in your own skin.
|
||||
data/example/wavs/007.wav|EN-default|EN|Additionally, staying up-to-date with fashion trends can help you develop your own sense of style and learn how to put together outfits that make you look and feel great.
|
||||
data/example/wavs/008.wav|EN-default|EN|That's a great point.
|
||||
data/example/wavs/009.wav|EN-default|EN|Do you think it's important to stay on top of the latest fashion trends, or is it more important to focus on timeless style?
|
||||
data/example/wavs/010.wav|EN-default|EN|I think it's really up to each individual to decide what approach to fashion works best for them.
|
||||
data/example/wavs/011.wav|EN-default|EN|Some people prefer to stick with classic, timeless styles that never go out of fashion, while others enjoy experimenting with new and innovative trends.
|
||||
data/example/wavs/012.wav|EN-default|EN|Ultimately, fashion is about personal expression and there's no right or wrong way to approach it.
|
||||
data/example/wavs/013.wav|EN-default|EN|The most important thing is to wear what makes you feel good and confident.
|
||||
data/example/wavs/014.wav|EN-default|EN|I completely agree.
|
||||
data/example/wavs/015.wav|EN-default|EN|Some popular ones that come to mind are oversized blazers, statement sleeves, printed maxi dresses, and chunky sneakers.
|
||||
data/example/wavs/016.wav|EN-default|EN|It's been really interesting chatting with you about fashion.
|
||||
data/example/wavs/017.wav|EN-default|EN|That's a good point.
|
||||
data/example/wavs/018.wav|EN-default|EN|What do you think are some current fashion trends that are popular right now?
|
||||
data/example/wavs/019.wav|EN-default|EN|There are so many trends happening right now, it's hard to keep track of them all!
|
||||
@@ -33,6 +33,7 @@ PRETRAINED_MODELS = {
|
||||
LANG_TO_HF_REPO_ID = {
|
||||
'EN': 'myshell-ai/MeloTTS-English',
|
||||
'EN_V2': 'myshell-ai/MeloTTS-English-v2',
|
||||
'EN_NEWEST': 'myshell-ai/MeloTTS-English-v3',
|
||||
'FR': 'myshell-ai/MeloTTS-French',
|
||||
'JP': 'myshell-ai/MeloTTS-Japanese',
|
||||
'ES': 'myshell-ai/MeloTTS-Spanish',
|
||||
|
||||
@@ -4,7 +4,7 @@ import glob
|
||||
import numpy as np
|
||||
import soundfile as sf
|
||||
import torchaudio
|
||||
from txtsplit import txtsplit
|
||||
import re
|
||||
|
||||
def split_sentence(text, min_len=10, language_str='EN'):
|
||||
if language_str in ['EN', 'FR', 'ES', 'SP']:
|
||||
@@ -13,13 +13,15 @@ def split_sentence(text, min_len=10, language_str='EN'):
|
||||
sentences = split_sentences_zh(text, min_len=min_len)
|
||||
return sentences
|
||||
|
||||
|
||||
def split_sentences_latin(text, min_len=10):
|
||||
text = re.sub('[。!?;]', '.', text)
|
||||
text = re.sub('[,]', ',', text)
|
||||
text = re.sub('[“”]', '"', text)
|
||||
text = re.sub('[‘’]', "'", text)
|
||||
text = re.sub(r"[\<\>\(\)\[\]\"\«\»]+", "", text)
|
||||
return [item.strip() for item in txtsplit(text, 512, 512) if item.strip()]
|
||||
return [item.strip() for item in txtsplit(text, 256, 512) if item.strip()]
|
||||
|
||||
|
||||
def split_sentences_zh(text, min_len=10):
|
||||
text = re.sub('[。!?;]', '.', text)
|
||||
@@ -45,6 +47,7 @@ def split_sentences_zh(text, min_len=10):
|
||||
new_sent = []
|
||||
return merge_short_sentences_zh(new_sentences)
|
||||
|
||||
|
||||
def merge_short_sentences_en(sens):
|
||||
"""Avoid short sentences by merging them with the following sentence.
|
||||
|
||||
@@ -70,6 +73,7 @@ def merge_short_sentences_en(sens):
|
||||
pass
|
||||
return sens_out
|
||||
|
||||
|
||||
def merge_short_sentences_zh(sens):
|
||||
# return sens
|
||||
"""Avoid short sentences by merging them with the following sentence.
|
||||
@@ -97,6 +101,67 @@ def merge_short_sentences_zh(sens):
|
||||
return sens_out
|
||||
|
||||
|
||||
|
||||
def txtsplit(text, desired_length=100, max_length=200):
|
||||
"""Split text it into chunks of a desired length trying to keep sentences intact."""
|
||||
text = re.sub(r'\n\n+', '\n', text)
|
||||
text = re.sub(r'\s+', ' ', text)
|
||||
text = re.sub(r'[""]', '"', text)
|
||||
text = re.sub(r'([,.?!])', r'\1 ', text)
|
||||
text = re.sub(r'\s+', ' ', text)
|
||||
|
||||
rv = []
|
||||
in_quote = False
|
||||
current = ""
|
||||
split_pos = []
|
||||
pos = -1
|
||||
end_pos = len(text) - 1
|
||||
def seek(delta):
|
||||
nonlocal pos, in_quote, current
|
||||
is_neg = delta < 0
|
||||
for _ in range(abs(delta)):
|
||||
if is_neg:
|
||||
pos -= 1
|
||||
current = current[:-1]
|
||||
else:
|
||||
pos += 1
|
||||
current += text[pos]
|
||||
if text[pos] == '"':
|
||||
in_quote = not in_quote
|
||||
return text[pos]
|
||||
def peek(delta):
|
||||
p = pos + delta
|
||||
return text[p] if p < end_pos and p >= 0 else ""
|
||||
def commit():
|
||||
nonlocal rv, current, split_pos
|
||||
rv.append(current)
|
||||
current = ""
|
||||
split_pos = []
|
||||
while pos < end_pos:
|
||||
c = seek(1)
|
||||
if len(current) >= max_length:
|
||||
if len(split_pos) > 0 and len(current) > (desired_length / 2):
|
||||
d = pos - split_pos[-1]
|
||||
seek(-d)
|
||||
else:
|
||||
while c not in '!?.\n ' and pos > 0 and len(current) > desired_length:
|
||||
c = seek(-1)
|
||||
commit()
|
||||
elif not in_quote and (c in '!?\n' or (c in '.,' and peek(1) in '\n ')):
|
||||
while pos < len(text) - 1 and len(current) < max_length and peek(1) in '!?.':
|
||||
c = seek(1)
|
||||
split_pos.append(pos)
|
||||
if len(current) >= desired_length:
|
||||
commit()
|
||||
elif in_quote and peek(1) == '"' and peek(2) in '\n ':
|
||||
seek(2)
|
||||
split_pos.append(pos)
|
||||
rv.append(current)
|
||||
rv = [s.strip() for s in rv]
|
||||
rv = [s for s in rv if len(s) > 0 and not re.match(r'^[\s\.,;:!?]*$', s)]
|
||||
return rv
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
zh_text = "好的,我来给你讲一个故事吧。从前有一个小姑娘,她叫做小红。小红非常喜欢在森林里玩耍,她经常会和她的小伙伴们一起去探险。有一天,小红和她的小伙伴们走到了森林深处,突然遇到了一只凶猛的野兽。小红的小伙伴们都吓得不敢动弹,但是小红并没有被吓倒,她勇敢地走向野兽,用她的智慧和勇气成功地制服了野兽,保护了她的小伙伴们。从那以后,小红变得更加勇敢和自信,成为了她小伙伴们心中的英雄。"
|
||||
en_text = "I didn’t know what to do. I said please kill her because it would be better than being kidnapped,” Ben, whose surname CNN is not using for security concerns, said on Wednesday. “It’s a nightmare. I said ‘please kill her, don’t take her there.’"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
txtsplit
|
||||
torch<2.0
|
||||
torch
|
||||
torchaudio
|
||||
cached_path
|
||||
transformers==4.27.4
|
||||
|
||||
Reference in New Issue
Block a user