Skip to content

Commit bd28aa7

Browse files
author
developer
committed
更新
1 parent 29725e8 commit bd28aa7

File tree

3 files changed

+11
-148
lines changed

3 files changed

+11
-148
lines changed

index.html

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212
<div class="container mt-5">
1313
<div class="card">
1414
<div class="card-header text-center">
15-
<h1>文本转语音</h1>
15+
<h2>文本转语音</h2>
1616
</div>
1717
<div class="card-body">
1818
<form id="text2voice-form">
19+
<!-- 新增的API选择 -->
1920
<div class="form-group">
2021
<label for="api">选择API:</label>
2122
<select class="form-control" id="api" required>
2223
<option value="aivoicenet">API 1</option>
23-
<option value="leftsite">API 2</option>
24+
<option value="voiceapi">API 2</option>
2425
</select>
2526
</div>
2627
<div id="commonParams">
@@ -33,7 +34,7 @@ <h1>文本转语音</h1>
3334
<select class="form-control" id="speaker" required></select>
3435
</div>
3536
</div>
36-
<div id="leftsiteParams" style="display: none;">
37+
<div id="voiceapiParams" style="display: none;">
3738
<div class="form-group slider-container">
3839
<label for="rate">语速: <span id="rateValue">0</span></label>
3940
<input type="range" class="form-control-range" id="rate" name="rate" min="-100" max="100" value="0">

script.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ const apiConfig = {
2222
"Ethan", "Emma", "Ava", "Lucas", "Chloe", "Caleb", "Sofia", "Gabriel", "Ivy"
2323
]
2424
},
25-
leftsite: {
26-
url: "/api2/tts",
25+
voiceapi: {
26+
url: "https://voiceapi.firefly.oy.lc/tts",
2727
speakers: [
2828
"zh-CN-XiaoxiaoMultilingualNeural", "zh-CN-XiaoxiaoNeural", "zh-CN-YunxiNeural", "zh-CN-YunjianNeural",
2929
"zh-CN-XiaoyiNeural", "zh-CN-YunyangNeural", "zh-CN-XiaochenNeural", "zh-CN-XiaohanNeural",
@@ -48,8 +48,8 @@ function updateSpeakerOptions(apiName) {
4848
speakerSelect.append(new Option(speaker, speaker));
4949
});
5050

51-
const showAdditionalParams = apiName === 'leftsite';
52-
$('#leftsiteParams').toggle(showAdditionalParams);
51+
const showAdditionalParams = apiName === 'voiceapi';
52+
$('#voiceapiParams').toggle(showAdditionalParams);
5353
}
5454

5555
function updateSliderLabel(sliderId, labelId) {
@@ -81,9 +81,9 @@ $(document).ready(function () {
8181
const apiUrl = apiConfig[apiName].url;
8282
const speaker = $('#speaker').val();
8383
const text = $('#text').val();
84-
8584
let url = `${apiUrl}?text=${encodeURIComponent(text)}&speak=${speaker}`;
86-
if (apiName === 'leftsite') {
85+
86+
if (apiName === 'voiceapi') {
8787
const rate = $('#rate').val();
8888
const pitch = $('#pitch').val();
8989
url += `&r=${rate}&p=${pitch}&o=audio-24khz-48kbitrate-mono-mp3`;
@@ -100,7 +100,7 @@ $(document).ready(function () {
100100
if (apiName === 'aivoicenet') {
101101
voiceUrl = response.voiceurl;
102102
} else {
103-
voiceUrl = URL.createObjectURL(response);
103+
voiceUrl = url;
104104
}
105105

106106
$('#audio').attr('src', voiceUrl);

worker.js

-138
This file was deleted.

0 commit comments

Comments
 (0)