Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,8 @@
|
|
| 12 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
# See the License for the specific language governing permissions and
|
| 14 |
# limitations under the License.
|
|
|
|
|
|
|
| 15 |
import os
|
| 16 |
import sys
|
| 17 |
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
@@ -63,6 +65,7 @@ def postprocess(speech, top_db=60, hop_length=220, win_length=440):
|
|
| 63 |
speech = torch.concat([speech, torch.zeros(1, int(target_sr * 0.2))], dim=1)
|
| 64 |
return speech
|
| 65 |
|
|
|
|
| 66 |
def generate_audio(tts_text, prompt_text, prompt_wav_upload, prompt_wav_record, seed, select_which):
|
| 67 |
if select_which == "上傳檔案" and prompt_wav_upload is not None:
|
| 68 |
prompt_wav = prompt_wav_upload
|
|
@@ -123,6 +126,7 @@ def demo_get_audio(tts_text):
|
|
| 123 |
speech, sample_rate = torchaudio.load(sample_wav)
|
| 124 |
|
| 125 |
return sample_rate, speech
|
|
|
|
| 126 |
def main():
|
| 127 |
with gr.Blocks(title="BreezyVoice 語音合成系統", theme="default") as demo:
|
| 128 |
# Title and About section at the top
|
|
@@ -133,14 +137,9 @@ def main():
|
|
| 133 |
with gr.Row():
|
| 134 |
gr.Image(value="https://raw.githubusercontent.com/Splend1d/BreezyVoice/main/images/flowchart.png", interactive=False, scale=3)
|
| 135 |
gr.Markdown(
|
| 136 |
-
"""#### 此沙盒使用 Huggingface
|
| 137 |
-
1. **強烈建議**複製這個 Space(Duplicate this space),以分散流量!
|
| 138 |
-
2. 複製至本地GPU執行(請參考[指南](https://huggingface.co/docs/hub/en/spaces-overview))或使用[kaggle](https://www.kaggle.com/code/a24998667/breezyvoice-playground)
|
| 139 |
-
3. 複製至本地CPU執行(請參考[指南](https://huggingface.co/docs/hub/en/spaces-overview))
|
| 140 |
-
|
| 141 |
-
為了加快推理速度,g2pw注音標註並未被啟動。
|
| 142 |
|
| 143 |
-
|
| 144 |
)
|
| 145 |
|
| 146 |
# All content arranged in a single column
|
|
@@ -151,16 +150,16 @@ def main():
|
|
| 151 |
|
| 152 |
# Grouping prompt audio inputs and auto speech recognition in one block using Markdown
|
| 153 |
gr.Markdown("### 步驟 1. 音訊樣本輸入 & 音訊樣本文本輸入")
|
| 154 |
-
gr.Markdown("選擇prompt音訊檔案或錄製prompt音訊 (5~15秒),並手動校對自動產生的音訊樣本文本。")
|
| 155 |
prompt_wav_upload = gr.Audio(
|
| 156 |
sources='upload',
|
| 157 |
type='filepath',
|
| 158 |
-
label='選擇prompt音訊檔案(確保取樣率不低於16khz)'
|
| 159 |
)
|
| 160 |
prompt_wav_record = gr.Audio(
|
| 161 |
sources='microphone',
|
| 162 |
type='filepath',
|
| 163 |
-
label='錄製prompt音訊檔案'
|
| 164 |
)
|
| 165 |
|
| 166 |
with gr.Blocks():
|
|
|
|
| 12 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
# See the License for the specific language governing permissions and
|
| 14 |
# limitations under the License.
|
| 15 |
+
import spaces
|
| 16 |
+
|
| 17 |
import os
|
| 18 |
import sys
|
| 19 |
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
| 65 |
speech = torch.concat([speech, torch.zeros(1, int(target_sr * 0.2))], dim=1)
|
| 66 |
return speech
|
| 67 |
|
| 68 |
+
@spaces.GPU
|
| 69 |
def generate_audio(tts_text, prompt_text, prompt_wav_upload, prompt_wav_record, seed, select_which):
|
| 70 |
if select_which == "上傳檔案" and prompt_wav_upload is not None:
|
| 71 |
prompt_wav = prompt_wav_upload
|
|
|
|
| 126 |
speech, sample_rate = torchaudio.load(sample_wav)
|
| 127 |
|
| 128 |
return sample_rate, speech
|
| 129 |
+
|
| 130 |
def main():
|
| 131 |
with gr.Blocks(title="BreezyVoice 語音合成系統", theme="default") as demo:
|
| 132 |
# Title and About section at the top
|
|
|
|
| 137 |
with gr.Row():
|
| 138 |
gr.Image(value="https://raw.githubusercontent.com/Splend1d/BreezyVoice/main/images/flowchart.png", interactive=False, scale=3)
|
| 139 |
gr.Markdown(
|
| 140 |
+
"""#### 此沙盒使用 Huggingface Zero GPU (A100)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
|
| 142 |
+
為了加快推理速度,g2pw注音標註並未被啟動。"""
|
| 143 |
)
|
| 144 |
|
| 145 |
# All content arranged in a single column
|
|
|
|
| 150 |
|
| 151 |
# Grouping prompt audio inputs and auto speech recognition in one block using Markdown
|
| 152 |
gr.Markdown("### 步驟 1. 音訊樣本輸入 & 音訊樣本文本輸入")
|
| 153 |
+
gr.Markdown("選擇 prompt 音訊檔案或錄製 prompt 音訊 (5~15秒),並手動校對自動產生的音訊樣本文本。")
|
| 154 |
prompt_wav_upload = gr.Audio(
|
| 155 |
sources='upload',
|
| 156 |
type='filepath',
|
| 157 |
+
label='選擇 prompt 音訊檔案(確保取樣率不低於 16khz)'
|
| 158 |
)
|
| 159 |
prompt_wav_record = gr.Audio(
|
| 160 |
sources='microphone',
|
| 161 |
type='filepath',
|
| 162 |
+
label='錄製 prompt 音訊檔案'
|
| 163 |
)
|
| 164 |
|
| 165 |
with gr.Blocks():
|