Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import torch
|
3 |
+
from DPTNet_eval.DPTNet_quant_sep import load_dpt_model, dpt_sep_process
|
4 |
+
|
5 |
+
# 加載模型
|
6 |
+
model = load_dpt_model()
|
7 |
+
|
8 |
+
def separate_audio(input_wav):
|
9 |
+
outfilename = "output.wav"
|
10 |
+
dpt_sep_process(input_wav, model=model, outfilename=outfilename)
|
11 |
+
return (
|
12 |
+
outfilename.replace('.wav', '_sep1.wav'),
|
13 |
+
outfilename.replace('.wav', '_sep2.wav')
|
14 |
+
)
|
15 |
+
|
16 |
+
# 🎯 你提供的 description 內容(已轉為 HTML)
|
17 |
+
description_html = """
|
18 |
+
<h1 align='center'><a href='https://www.twman.org/AI/ASR/SpeechSeparation' target='_blank'>中文語者分離(分割)</a></h1>
|
19 |
+
<p align='center'><b>上傳一段混音音檔,自動分離出兩個人的聲音</b></p>
|
20 |
+
|
21 |
+
<div align='center'>
|
22 |
+
<a href='https://www.twman.org' target='_blank'>TonTon Huang Ph.D.</a> |
|
23 |
+
<a href='https://blog.twman.org/p/deeplearning101.html' target='_blank'>手把手帶你一起踩AI坑</a> |
|
24 |
+
<a href='https://github.com/Deep-Learning-101' target='_blank'>GitHub</a> |
|
25 |
+
<a href='http://deeplearning101.twman.org' target='_blank'>Deep Learning 101</a>
|
26 |
+
</div>
|
27 |
+
|
28 |
+
<br><br>
|
29 |
+
|
30 |
+
### 🔍 使用方式:
|
31 |
+
- 上傳一段包含兩人對話的混音音檔(支援 `.mp3`, `.wav`)
|
32 |
+
- 點擊「Separate」按鈕
|
33 |
+
- 分離出兩個說話人的音軌
|
34 |
+
|
35 |
+
<br><br>
|
36 |
+
|
37 |
+
### 📘 相關技術文章:
|
38 |
+
<ul>
|
39 |
+
<li><a href='https://blog.twman.org/2025/03/AIAgent.html' target='_blank'>避開 AI Agent 開發陷阱:常見問題、挑戰與解決方案 (那些 AI Agent 實戰踩過的坑)</a>:探討多種 AI Agent 工具的應用經驗與挑戰</li>
|
40 |
+
<li><a href='https://blog.twman.org/2024/08/LLM.html' target='_blank'>白話文手把手帶你科普 GenAI</a>:淺顯介紹生成式人工智慧核心概念</li>
|
41 |
+
<li><a href='https://blog.twman.org/2024/09/LLM.html' target='_blank'>大型語言模型直接就打完收工?</a>:回顧 LLM 領域探索歷程</li>
|
42 |
+
<li><a href='https://blog.twman.org/2024/07/RAG.html' target='_blank'>檢索增強生成 (Retrieval-Augmented Generation, RAG) 不是萬靈丹之優化挑戰技巧</a>:探討 RAG 技術應用與挑戰</li>
|
43 |
+
<li><a href='https://blog.twman.org/2024/02/LLM.html' target='_blank'>大型語言模型 (LLM) 入門完整指南:原理、應用與未來</a>:探討多種 LLM 工具的應用與挑戰</li>
|
44 |
+
<li><a href='https://blog.twman.org/2023/04/GPT.html' target='_blank'>什麼是大語言模型,它是什麼?想要嗎?(Large Language Model,LLM)</a>:探討 LLM 的發展與應用</li>
|
45 |
+
<li><a href='https://blog.twman.org/2024/11/diffusion.html' target='_blank'>ComfyUI + Stable Diffuision</a>:深入探討影像生成與分割技術的應用</li>
|
46 |
+
<li><a href='https://blog.twman.org/2024/02/asr-tts.html' target='_blank'>ASR/TTS 開發避坑指南:語音辨識與合成的常見挑戰與對策</a>:探討 ASR 和 TTS 技術應用中的問題</li>
|
47 |
+
<li><a href='https://blog.twman.org/2021/04/NLP.html' target='_blank'>那些自然語言處理 (NLP) 踩的坑</a>:分享 NLP 領域的實踐經驗</li>
|
48 |
+
<li><a href='https://blog.twman.org/2021/04/ASR.html' target='_blank'>那些語音處理 (Speech Processing) 踩的坑</a>:分享語音處理領域的實務經驗</li>
|
49 |
+
<li><a href='https://blog.twman.org/2023/07/wsl.html' target='_blank'>用PPOCRLabel來幫PaddleOCR做OCR的微調和標註</a></li>
|
50 |
+
<li><a href='https://blog.twman.org/2023/07/HugIE.html' target='_blank'>基於機器閱讀理解和指令微調的統一信息抽取框架之診斷書醫囑資訊擷取分析</a></li>
|
51 |
+
<li><a href='https://github.com/shibing624/pycorrector' target='_blank'>Masked Language Model (MLM) as correction BERT</a></li>
|
52 |
+
</ul>
|
53 |
+
|
54 |
+
<br><br>
|
55 |
+
|
56 |
+
📢 *本模型基於 PyTorch + Hugging Face Hub 私有模型部署*
|
57 |
+
"""
|
58 |
+
|
59 |
+
# 📋 你提供的 examples(可替換成你自己的測試音檔)
|
60 |
+
examples = [
|
61 |
+
["examples/sample1.wav"], # 替換成你的音檔路徑
|
62 |
+
["examples/sample2.mp3"],
|
63 |
+
]
|
64 |
+
|
65 |
+
if __name__ == "__main__":
|
66 |
+
interface = gr.Interface(
|
67 |
+
fn=separate_audio,
|
68 |
+
inputs=gr.Audio(type="filepath", label="請上傳混音音檔 (.mp3/.wav)"),
|
69 |
+
outputs=[
|
70 |
+
gr.Audio(label="語音 1"),
|
71 |
+
gr.Audio(label="語音 2")
|
72 |
+
],
|
73 |
+
title="🎙️ 語音分離 Demo - Deep Learning 101",
|
74 |
+
description=description_html,
|
75 |
+
examples=examples,
|
76 |
+
allow_flagging="never"
|
77 |
+
)
|
78 |
+
|
79 |
+
interface.launch()
|