Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,21 +17,6 @@ import nltk
|
|
| 17 |
# 設定 HTTPS context 避免證書錯誤
|
| 18 |
ssl._create_default_https_context = ssl._create_unverified_context
|
| 19 |
|
| 20 |
-
# 🛠 安裝相容的 LangSegment(v0.1.5)
|
| 21 |
-
def install_compatible_LangSegment():
|
| 22 |
-
try:
|
| 23 |
-
subprocess.check_call([
|
| 24 |
-
os.sys.executable, "-m", "pip",
|
| 25 |
-
"install", "LangSegment==0.1.5",
|
| 26 |
-
"-i", "https://pypi.org/simple",
|
| 27 |
-
"--force-reinstall"
|
| 28 |
-
])
|
| 29 |
-
print("✅ LangSegment 降級成功")
|
| 30 |
-
except subprocess.CalledProcessError:
|
| 31 |
-
print("❌ LangSegment 降級失敗")
|
| 32 |
-
|
| 33 |
-
install_compatible_LangSegment()
|
| 34 |
-
|
| 35 |
# 🧠 下載 NLTK 所需資源
|
| 36 |
nltk_data_path = os.path.expanduser('~/nltk_data')
|
| 37 |
if not os.path.exists(os.path.join(nltk_data_path, 'corpora/cmudict.zip')):
|
|
@@ -39,6 +24,8 @@ if not os.path.exists(os.path.join(nltk_data_path, 'corpora/cmudict.zip')):
|
|
| 39 |
if not os.path.exists(os.path.join(nltk_data_path, 'taggers/averaged_perceptron_tagger.zip')):
|
| 40 |
nltk.download('averaged_perceptron_tagger', download_dir=nltk_data_path)
|
| 41 |
|
|
|
|
|
|
|
| 42 |
# 📦 匯入 parrots
|
| 43 |
from parrots import TextToSpeech
|
| 44 |
|
|
|
|
| 17 |
# 設定 HTTPS context 避免證書錯誤
|
| 18 |
ssl._create_default_https_context = ssl._create_unverified_context
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
# 🧠 下載 NLTK 所需資源
|
| 21 |
nltk_data_path = os.path.expanduser('~/nltk_data')
|
| 22 |
if not os.path.exists(os.path.join(nltk_data_path, 'corpora/cmudict.zip')):
|
|
|
|
| 24 |
if not os.path.exists(os.path.join(nltk_data_path, 'taggers/averaged_perceptron_tagger.zip')):
|
| 25 |
nltk.download('averaged_perceptron_tagger', download_dir=nltk_data_path)
|
| 26 |
|
| 27 |
+
import LangSegment
|
| 28 |
+
|
| 29 |
# 📦 匯入 parrots
|
| 30 |
from parrots import TextToSpeech
|
| 31 |
|