Spaces:
Runtime error
Runtime error
ww
commited on
Commit
·
4b9d080
1
Parent(s):
ba86a1a
- README.md +7 -7
- app.py +15 -35
- packages.txt +1 -3
- requirements.txt +3 -3
- simfang.ttf +0 -3
README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
-
sdk:
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
| 11 |
---
|
| 12 |
|
| 13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces
|
|
|
|
| 1 |
---
|
| 2 |
+
title: PaddleSpeechTTS
|
| 3 |
+
emoji: 🚀
|
| 4 |
+
colorFrom: pink
|
| 5 |
+
colorTo: blue
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 2.8.10
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
| 11 |
---
|
| 12 |
|
| 13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
|
app.py
CHANGED
|
@@ -1,40 +1,20 @@
|
|
| 1 |
import os
|
| 2 |
-
|
| 3 |
-
os.system('pip install paddleocr')
|
| 4 |
-
from paddleocr import PaddleOCR, draw_ocr
|
| 5 |
-
from PIL import Image
|
| 6 |
import gradio as gr
|
| 7 |
-
import
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
def inference(img, lang):
|
| 12 |
-
ocr = PaddleOCR(use_angle_cls=True, lang=lang,use_gpu=False)
|
| 13 |
-
img_path = img.name
|
| 14 |
-
result = ocr.ocr(img_path, cls=True)[0]
|
| 15 |
-
image = Image.open(img_path).convert('RGB')
|
| 16 |
-
boxes = [line[0] for line in result]
|
| 17 |
-
txts = [line[1][0] for line in result]
|
| 18 |
-
scores = [line[1][1] for line in result]
|
| 19 |
-
im_show = draw_ocr(image, boxes, txts, scores,
|
| 20 |
-
font_path='simfang.ttf')
|
| 21 |
-
im_show = Image.fromarray(im_show)
|
| 22 |
-
im_show.save('result.jpg')
|
| 23 |
-
return 'result.jpg'
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
inference,
|
| 32 |
-
[gr.inputs.Image(type='file', label='Input'),gr.inputs.Dropdown(choices=['ch', 'en', 'fr', 'german', 'korean', 'japan'], type="value", default='en', label='language')],
|
| 33 |
-
gr.outputs.Image(type='file', label='Output'),
|
| 34 |
-
title=title,
|
| 35 |
-
description=description,
|
| 36 |
-
article=article,
|
| 37 |
-
examples=examples,
|
| 38 |
-
css=css,
|
| 39 |
-
enable_queue=True
|
| 40 |
-
).launch(debug=True)
|
|
|
|
| 1 |
import os
|
| 2 |
+
|
|
|
|
|
|
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
+
from paddlespeech.cli import TTSExecutor
|
| 5 |
+
|
| 6 |
+
tts_executor = TTSExecutor()
|
| 7 |
+
|
| 8 |
|
| 9 |
+
def speech_generate(text: str) -> os.PathLike:
|
| 10 |
+
assert isinstance(text, str) and len(text) > 0, 'Input Chinese text...'
|
| 11 |
+
wav_file = tts_executor(text=text)
|
| 12 |
+
return wav_file
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
iface = gr.Interface(
|
| 16 |
+
fn=speech_generate,
|
| 17 |
+
inputs=gr.inputs.Textbox(placeholder='请输入文字...'),
|
| 18 |
+
outputs=gr.outputs.Audio(),
|
| 19 |
+
)
|
| 20 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
packages.txt
CHANGED
|
@@ -1,3 +1 @@
|
|
| 1 |
-
|
| 2 |
-
libsm6
|
| 3 |
-
libxext6
|
|
|
|
| 1 |
+
libsndfile1
|
|
|
|
|
|
requirements.txt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
| 1 |
+
paddlepaddle
|
| 2 |
+
paddleaudio
|
| 3 |
+
paddlespeech
|
simfang.ttf
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:521c6f7546b4eb64fa4b0cd604bbd36333a20a57e388c8e2ad2ad07b9e593864
|
| 3 |
-
size 10576012
|
|
|
|
|
|
|
|
|
|
|
|