AkitoP commited on
Commit
c8ad912
1 Parent(s): b3e26b1
Files changed (1) hide show
  1. app.py +1 -21
app.py CHANGED
@@ -52,27 +52,7 @@ logging.getLogger('multipart').setLevel(logging.WARNING)
52
  device = "cuda" if torch.cuda.is_available() else "cpu"
53
  #device = "cpu"
54
  is_half = False
55
-
56
- tokenizer = AutoTokenizer.from_pretrained(bert_path)
57
- bert_model=AutoModelForMaskedLM.from_pretrained(bert_path)
58
- if(is_half==True):bert_model=bert_model.half().to(device)
59
- else:bert_model=bert_model.to(device)
60
  # bert_model=bert_model.to(device)
61
- def get_bert_feature(text, word2ph): # Bert(不是HuBERT的特征计算)
62
- with torch.no_grad():
63
- inputs = tokenizer(text, return_tensors="pt")
64
- for i in inputs:
65
- inputs[i] = inputs[i].to(device)#####输入是long不用管精度问题,精度随bert_model
66
- res = bert_model(**inputs, output_hidden_states=True)
67
- res = torch.cat(res["hidden_states"][-3:-2], -1)[0].cpu()[1:-1]
68
- assert len(word2ph) == len(text)
69
- phone_level_feature = []
70
- for i in range(len(word2ph)):
71
- repeat_feature = res[i].repeat(word2ph[i], 1)
72
- phone_level_feature.append(repeat_feature)
73
- phone_level_feature = torch.cat(phone_level_feature, dim=0)
74
- # if(is_half==True):phone_level_feature=phone_level_feature.half()
75
- return phone_level_feature.T
76
 
77
  loaded_sovits_model = [] # [(path, dict, model)]
78
  loaded_gpt_model = []
@@ -364,7 +344,7 @@ with gr.Blocks() as app:
364
  )
365
  prompt_language = gr.State(value="ja")
366
  with gr.Column():
367
- text = gr.Textbox(label="Input Text", value="こんにちは、私はあなたのAIアシスタントです。仲良くしましょうね。")
368
  text_language = gr.Dropdown(
369
  label="Language",
370
  choices=["ja"],
 
52
  device = "cuda" if torch.cuda.is_available() else "cpu"
53
  #device = "cpu"
54
  is_half = False
 
 
 
 
 
55
  # bert_model=bert_model.to(device)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
  loaded_sovits_model = [] # [(path, dict, model)]
58
  loaded_gpt_model = []
 
344
  )
345
  prompt_language = gr.State(value="ja")
346
  with gr.Column():
347
+ text = gr.Textbox(label="Input Text", value="学園アイドルマスター!")
348
  text_language = gr.Dropdown(
349
  label="Language",
350
  choices=["ja"],