Artrajz commited on
Commit
7a79fa7
1 Parent(s): 87ec8e7

update index

Browse files
Files changed (1) hide show
  1. templates/index.html +34 -4
templates/index.html CHANGED
@@ -19,13 +19,13 @@
19
  </div>
20
  <div>
21
  <label>返回speakers(json):</label>
22
- <a href="https://artrajz-vits-simple-api.hf.space/voice/speakers" target="_blank" style="text-decoration: none; color: black">
23
  https://artrajz-vits-simple-api.hf.space/voice/speakers
24
  </a>
25
  </div>
26
  <div>
27
  <label>简单调用api:</label>
28
- <a id="dynamicLink" href="https://artrajz-vits-simple-api.hf.space/voice/vits?text=你好,こんにちは&id=164" style="text-decoration: none; color: black">
29
  https://artrajz-vits-simple-api.hf.space/voice/vits?text=你好,こんにちは&id=164
30
  </a>
31
  </div>
@@ -148,6 +148,36 @@
148
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script>
149
 
150
  <script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  function getLink() {
152
  var text = document.getElementById("inputText").value;
153
  var id = document.getElementById("inputId").value;
@@ -158,7 +188,7 @@
158
  var noisew = document.getElementById("inputNoisew").value;
159
  var max = document.getElementById("inputMax").value;
160
 
161
- var url = "https://artrajz-vits-simple-api.hf.space/voice/vits?text=" + text + "&id=" + id;
162
  if (format != "") {
163
  url += "&format=" + format;
164
  }
@@ -182,7 +212,7 @@
182
 
183
  function updateLink() {
184
  var url = getLink();
185
- var link = document.getElementById("dynamicLink");
186
  link.href = url;
187
  link.textContent = url;
188
  }
 
19
  </div>
20
  <div>
21
  <label>返回speakers(json):</label>
22
+ <a id="speakersLink" href="https://artrajz-vits-simple-api.hf.space/voice/speakers" target="_blank" style="text-decoration: none; color: black">
23
  https://artrajz-vits-simple-api.hf.space/voice/speakers
24
  </a>
25
  </div>
26
  <div>
27
  <label>简单调用api:</label>
28
+ <a id="vitsLink" href="https://artrajz-vits-simple-api.hf.space/voice/vits?text=你好,こんにちは&id=164" style="text-decoration: none; color: black">
29
  https://artrajz-vits-simple-api.hf.space/voice/vits?text=你好,こんにちは&id=164
30
  </a>
31
  </div>
 
148
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script>
149
 
150
  <script>
151
+ function getProtocol(){
152
+ return 'https:' == location.protocol ? "https://": "http://";
153
+ }
154
+
155
+ function getUrl(){
156
+ var url = window.location.host;
157
+ return url;
158
+ }
159
+
160
+ var baseUrl = getProtocol() + getUrl();
161
+
162
+ setBaseUrl();
163
+
164
+ function setBaseUrl(){
165
+ var text = document.getElementById("inputText").value;
166
+ var id = document.getElementById("inputId").value;
167
+
168
+ var vitsLink = document.getElementById("vitsLink");
169
+ var speakersLink = document.getElementById("speakersLink");
170
+
171
+ var vitsUrl = baseUrl + "/voice/vits?text=" + text + "&id=" + id;
172
+ var speakersUrl = baseUrl + "/voice/speakers";
173
+
174
+ vitsLink.href = vitsUrl;
175
+ vitsLink.textContent = vitsUrl;
176
+
177
+ speakersLink.href = speakersUrl;
178
+ speakersLink.textContent = speakersUrl;
179
+ }
180
+
181
  function getLink() {
182
  var text = document.getElementById("inputText").value;
183
  var id = document.getElementById("inputId").value;
 
188
  var noisew = document.getElementById("inputNoisew").value;
189
  var max = document.getElementById("inputMax").value;
190
 
191
+ var url = baseUrl + "/voice/vits?text=" + text + "&id=" + id;
192
  if (format != "") {
193
  url += "&format=" + format;
194
  }
 
212
 
213
  function updateLink() {
214
  var url = getLink();
215
+ var link = document.getElementById("vitsLink");
216
  link.href = url;
217
  link.textContent = url;
218
  }