File size: 10,104 Bytes
26f34b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>vits-simple-api</title>

    <link rel="stylesheet" href="/static/css/bootstrap.min.css"/>
</head>
<body>
<main style="margin: 0 auto; width: 1024px">
    <h1>
        <a href="https://github.com/Artrajz/vits-simple-api" target="_blank"
           style="text-decoration: none; color: black"> vits-simple-api </a>
    </h1>

    <div>
        <label>文档:</label>
        <a href="https://github.com/Artrajz/vits-simple-api" target="_blank"
           style="text-decoration: none; color: black"> https://github.com/Artrajz/vits-simple-api </a>
    </div>
    <div>
        <label>返回speakers(json):</label>
        <a id="speakersLink" href="https://artrajz-vits-simple-api.hf.space/voice/speakers" target="_blank"
           style="text-decoration: none; color: black">
            https://artrajz-vits-simple-api.hf.space/voice/speakers
        </a>
    </div>
    <div>
        <label>简单调用api:</label>
        <a id="vitsLink" href="https://artrajz-vits-simple-api.hf.space/voice/vits?text=你好,こんにちは&id=164"
           style="text-decoration: none; color: black">
            https://artrajz-vits-simple-api.hf.space/voice/vits?text=你好,こんにちは&id=164
        </a>
    </div>

    <!-- <div style="display: flex; justify-content: center; align-items: center"> -->
    <div>
        <form>
            <div class="form-group">
                <label>text</label>
                <textarea class="form-control" id="inputText" rows="3" oninput="updateLink()">你好,こんにちは</textarea>
            </div>
            <div class="form-group">
                <label>id</label>
                <select class="form-control" id="inputId" oninput="updateLink()">
                    {% for speaker in speakers["VITS"] %}
                        {% if speaker["name"] == "雷电将军(雷神)" %}
                            <option value="{{ speaker["id"] }}" selected>{{ speaker["id"] }} | {{ speaker["name"] }}
                                | {{ speaker["lang"] }}</option>
                        {% else %}
                            <option value="{{ speaker["id"] }}">{{ speaker["id"] }} | {{ speaker["name"] }}
                                | {{ speaker["lang"] }}</option>
                        {% endif %}
                    {% endfor %}
                </select>
            </div>
        </form>
    </div>
    <p>
        <button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample"
                aria-expanded="false" aria-controls="collapseExample">
            Advanced
        </button>
        {% if speakers_count == 0 %}
            <div style="color: red;">未加载任何模型</div>
        {% endif %}
    </p>
    <div class="collapse" id="collapseExample">
        <div class="card card-body">
            <form>
                <div class="form-group">
                    <label>format</label>
                    <select class="form-control" id="inputFormat" oninput="updateLink()">
                        <option></option>
                        <option>wav</option>
                        <option>mp3</option>
                        <option>ogg</option>
                        <option>silk</option>
                    </select>
                </div>
                <div class="form-group">
                    <label>lang</label>
                    <input type="text" class="form-control" id="inputLang" oninput="updateLink()" value=""
                           placeholder="auto"/>
                </div>
                <div class="form-group">
                    <label>length</label>
                    <input type="text" class="form-control" id="inputLength" oninput="updateLink()" value=""
                           placeholder="1"/>
                </div>
                <div class="form-group">
                    <label>noise</label>
                    <input type="text" class="form-control" id="inputNoise" oninput="updateLink()" value=""
                           placeholder="0.33"/>
                </div>
                <div class="form-group">
                    <label>noisew</label>
                    <input type="text" class="form-control" id="inputNoisew" oninput="updateLink()" value=""
                           placeholder="0.4"/>
                </div>
                <div class="form-group">
                    <label>max</label>
                    <input type="text" class="form-control" id="inputMax" oninput="updateLink()" value=""
                           placeholder="50"/>
                </div>
            </form>
        </div>
    </div>

    <div style="display: flex; justify-content: center; align-items: center; height: 80px; margin-top: 20px; margin-bottom: 20px; border: 1px solid rgba(0,0,0,.125); border-radius: 0.25rem;">
        <button type="button" class="btn btn-outline-secondary" id="getAudio" style="margin-right: 10px">播放器生成</button>
        <audio id="audioPlayer" controls>
            <source src="" type="audio/mp3"/>
            Your browser does not support the audio element.
        </audio>
        <div class="form-group form-check">
            <input type="checkbox" id="streaming" onchange="updateLink()">
            <label class="form-check-label">流式响应</label>
        </div>
    </div>
    <div>自动识别语言:可识别的语言根据不同speaker而不同,方言无法自动识别</div>
    <div>方言模型需要手动指定语言,比如粤语Cantonese要指定参数lang=gd</div>
    <br/>

    <h2>所有模型均为网络搜集,感谢模型原作者的付出!</h2>
    <p>
        Nene_Nanami_Rong_Tang:
        <a href="https://github.com/CjangCjengh/TTSModels" rel="noreferrer" target="_blank">CjangCjengh/TTSModels</a>
    </p>
    <p>
        louise:
        <a href="https://github.com/CjangCjengh/TTSModels" rel="noreferrer" target="_blank">CjangCjengh/TTSModels</a>
    </p>
    <p>
        Cantonese:
        <a href="https://github.com/CjangCjengh/TTSModels" rel="noreferrer" target="_blank">CjangCjengh/TTSModels</a>
    </p>
    <p>
        shanghainese:
        <a href="https://github.com/CjangCjengh/TTSModels" rel="noreferrer" target="_blank">CjangCjengh/TTSModels</a>
    </p>
    <p>
        w2v2-vits:
        <a href="https://github.com/CjangCjengh/TTSModels" rel="noreferrer" target="_blank">CjangCjengh/TTSModels</a>
    </p>
    <p>
        vctk:
        <a href="https://github.com/jaywalnut310/vits" rel="noreferrer" target="_blank">jaywalnut310/vits</a>
    </p>
    <p>
        Bishojo Mangekyo:
        <a href="https://github.com/Francis-Komizu/VITS" rel="noreferrer" target="_blank">Francis-Komizu/VITS</a>
    </p>
    <p>
        genshin:
        <a href="https://huggingface.co/spaces/zomehwh/vits-uma-genshin-honkai" rel="noreferrer" target="_blank">zomehwh/vits-uma-genshin-honkai</a>
    </p>
    <p>
        paimon:
        <a href="https://github.com/zixiiu/Digital_Life_Server" rel="noreferrer" target="_blank">zixiiu/Digital_Life_Server</a>
    </p>
    <p>
        vits_chinese:
        <a href="https://github.com/PlayVoice/vits_chinese" rel="noreferrer" target="_blank">PlayVoice/vits_chinese</a>
    </p>

</main>

<script src="/static/js/jquery.slim.min.js"></script>
<script src="/static/js/bootstrap.bundle.min.js"></script>

<script>
    function getProtocol() {
        return 'https:' == location.protocol ? "https://" : "http://";
    }

    function getUrl() {
        var url = window.location.host;
        return url;
    }

    var baseUrl = getProtocol() + getUrl();

    setBaseUrl();

    function setBaseUrl() {
        var text = document.getElementById("inputText").value;
        var id = document.getElementById("inputId").value;

        var vitsLink = document.getElementById("vitsLink");
        var speakersLink = document.getElementById("speakersLink");

        var vitsUrl = baseUrl + "/voice/vits?text=" + text + "&id=" + id;
        var speakersUrl = baseUrl + "/voice/speakers";

        vitsLink.href = vitsUrl;
        vitsLink.textContent = vitsUrl;

        speakersLink.href = speakersUrl;
        speakersLink.textContent = speakersUrl;
    }

    function getLink() {
        var text = document.getElementById("inputText").value;
        var id = document.getElementById("inputId").value;
        var format = document.getElementById("inputFormat").value;
        var lang = document.getElementById("inputLang").value;
        var length = document.getElementById("inputLength").value;
        var noise = document.getElementById("inputNoise").value;
        var noisew = document.getElementById("inputNoisew").value;
        var max = document.getElementById("inputMax").value;
        var streaming = document.getElementById('streaming');

        var url = baseUrl + "/voice/vits?text=" + text + "&id=" + id;
        if (format != "") {
            url += "&format=" + format;
        }
        if (lang != "") {
            url += "&lang=" + lang;
        }
        if (length != "") {
            url += "&length=" + length;
        }
        if (noise != "") {
            url += "&noise=" + noise;
        }
        if (noisew != "") {
            url += "&noisew=" + noisew;
        }
        if (max != "") {
            url += "&max=" + max;
        }
        if (streaming.checked) {
            url += '&streaming=true';
        }
        return url;
    }

    function updateLink() {
        var url = getLink();
        var link = document.getElementById("vitsLink");
        link.href = url;
        link.textContent = url;
    }

    function setAudioSource() {
        var url = getLink();
        var audioPlayer = document.getElementById("audioPlayer");
        audioPlayer.src = url;
        audioPlayer.play();
    }

    var button = document.getElementById("getAudio");
    button.addEventListener("click", function () {
        setAudioSource();
    });
</script>
</body>
</html>