Coder Social home page Coder Social logo

softvc's Introduction

VITS_WebUI

A WebUI for text-to-speech inference based on the Vits model

一个基于Vits模型的文本转语音推理WebUI

Preview 项目预览:

image

image

Features

  • Text to Speech inference 文本转语音推理
  • Generate parameter adjustment 生成参数调整
  • Export generated audio 导出生成音频
  • Import model information 导入模型信息:name_en、name_ch、Speaker ID、Example text、Cover、Language
  • Import model error message 导入模型错误提示
  • Display model information 模型信息显示
  • Switch checkpoints 切换模型
  • Display example text 实例文本显示

Terms of Use

🚨Please resolve the dataset authorization issues by yourself. Any problems caused by using unauthorized datasets for training are at your own risk and responsibility.This project does not provide datasets or model files.

🚨请自行解决数据集授权问题,任何因使用未经授权的数据集进行训练而造成的问题,由您自行承担风险和责任。本项目不提供数据集以及模型文件。

Getting started

using Gradio 3.25.0

1.Install requirment 安装依赖

pip install - r requirements.txt

2.Runsetup.py 启动环境

%cd VITS_WebUI\monotonic_align
!python setup.py build_ext --inplace

单调对齐搜索,一种搜索最大化的,由归一化流参数化的数据的对齐的方法。

3.Run interface 启动界面

%cd VITS_WebUI
!python app.py

或者你也可以执行此文件GUI_Usage.ipynb

4.View in browser 在浏览器中查看

http://127.0.0.1:7860/

5.在Settings中导入模型信息,并将训练好的checkpoints文件改名为对应name_en.pth并放到models目录下对应生成的文件夹中。

首次运行请在models/Yuuka中放入任意checkpoints

Detail

如果你想在此项目上修改,可以参考这里

Inference-related functions

  • get_text(text, hps):文本预处理函数,能够将输入文本转换为音素
  • tts_fn(text, noise_scale, noise_scale_w, length_scale):推理函数,给定三个超参数noise_scalenoise_scale_wlength_scale用于控制生成音频的情感变化长度发音长度语速

Gradio-related function

Gradio具有丰富的案例Demo和详尽的开发文档,入门请参考这些网站

  • get_options():从models/model_info.json该json文件中获取模型信息

  • add_model_fn():导入模型信息函数,支持导入以下参数:example_textcoverspeakerIDname_enname_cnlanguage

    speakerIDname_enlanguage为必填选项,如果为空则会提升错误

    # 检查必填字段是否为空
    if not SPEAKER_ID or not name_en or not language:
        raise gr.Error("Please fill in all required fields!")
        return "Failed to add model"

    如果要执行gr.Error,必须在click方法中添加一个组件到outputs,否则会报错,这里我选择的是一个Textbox组件

  • change_dropdown():更新模型信息函数,当Dropdown选取新的模型时,实时地更新

    注意:

    • 由于Gradio的update()方法无法更新Example组件,于是用Textbox来替代示例

    • 声明了Global全局变量

    • 需要在Blocks里面添加change函数

      model_choice.change(fn=change_dropdown, inputs=model_choice, outputs=[speaker_id_choice,cover_markdown,title_markdown,lan,example_text_box])
  • CustomEncoder(json.JSONEncoder):json编码器类,用于解决在执行json.dump()时出现的格式错误

  • download_audio_js:JS方法,用来下载生成的音频,保存的文件名为Input Textbox中的文本截取

    需要为作为InputsTextbox组件添加一个elem_id

    elem_id=f"input-text-en-{name_en.replace(' ','')}",

    以及为作为OutputsAudio组件添加一个elem_id

    output_audio = gr.Audio(label="Output", elem_id=f"tts-audio-en-{name_en.replace(' ','')}")

    该方法在download_button被点击时执行

    download_button.click(None, [], [], _js=download_audio_js.format(audio_id=f"en-{name_en.replace(' ', '')}"))

Layout

  • Blocks:

    能创建自定义的UI,搭配CSS食用更佳: https://gradio.app/custom-CSS-and-JS/

  • Markdown:

    gr.Markdown支持Markdown格式的输入,你也可以输入html文本

    gr.Markdown("""# Select Model""")
    cover_markdown = gr.Markdown(
        '<div align="center">'
        f'<img style="width:auto;height:512px;" src="file/{COVER}">' if COVER else ""
                                                                                   '</div>')
    title_markdown = gr.Markdown(
        '<div align="center">'
        f'<h3><a><strong>{"语音名称: "}{MODEL_ZH_NAME}</strong></a>'
        f'<h3><strong>{"checkpoint: "}{speaker_choice}</strong>'
                                                                                   '</div>')
  • Columns and Nesting

    你可以使用gr.Box()gr.Row()gr.Column来控制组件的布局

    只有Column能够使用scale来控制大小,如果想控制Row的大小,你可以采取以下嵌套方式

    with gr.Box():
        with gr.Row():
            with gr.Column(scale = 2):
                #Components 
            with gr.Column(scale = 1):
                #Components
  • Theme:

    我这里使用的是Base主题,你可以查看官方文档选择你想要的主题:https://gradio.app/theming-guide/

    theme = gr.themes.Base()
    
    with gr.Blocks(theme=theme) as interface:
        #Components 
        
    interface.queue(concurrency_count=1).launch(debug=True)

    queue(concurrency_count=1)开启可以显示进程的执行时间,debug这个参数默认是False,开启后可以使用debug功能,定位到错误信息。

Reference

softvc's People

Contributors

li-kira avatar

Stargazers

ZDP avatar

Watchers

 avatar

Forkers

cloutprotocol

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.