Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
3796a40e
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
大约 2 年 前同步成功
通知
210
Star
8425
Fork
1598
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
245
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DeepSpeech
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
245
Issue
245
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
3796a40e
编写于
1月 26, 2022
作者:
L
liangym
提交者:
GitHub
1月 26, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1389 from lym0302/tts-server2
add tts api
上级
e66233fa
eb7e964e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
62 addition
and
1 deletion
+62
-1
speechserving/speechserving/restful/tts_api.py
speechserving/speechserving/restful/tts_api.py
+62
-1
未找到文件。
speechserving/speechserving/restful/tts_api.py
浏览文件 @
3796a40e
...
...
@@ -11,8 +11,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
engine.tts.python.tts_engine
import
TTSEngine
from
fastapi
import
APIRouter
from
.request
import
TTSRequest
from
.response
import
TTSResponse
router
=
APIRouter
()
...
...
@@ -24,6 +27,64 @@ def help():
Returns:
json: [description]
"""
return
{
'hello'
:
'world'
}
json_body
=
{
"success"
:
true
,
"code"
:
0
,
"message"
:
{
"global"
:
"success"
},
"result"
:
{
"description"
:
"tts server"
,
"text"
:
"sentence to be synthesized"
,
"audio"
:
"the base64 of audio"
}
}
return
json_body
@
router
.
post
(
"/paddlespeech/tts"
,
response_model
=
TTSResponse
)
def
tts
(
request_body
:
TTSRequest
):
"""tts api
Args:
request_body (TTSRequest): [description]
Returns:
json: [description]
"""
# json to dict
item_dict
=
request_body
.
dict
()
sentence
=
item_dict
[
'text'
]
spk_id
=
item_dict
[
'spk_id'
]
speed
=
item_dict
[
'speed'
]
volume
=
item_dict
[
'volume'
]
sample_rate
=
item_dict
[
'sample_rate'
]
save_path
=
item_dict
[
'save_path'
]
audio_format
=
item_dict
[
'audio_format'
]
# single
tts_engine
=
TTSEngine
()
#tts_engine.init()
lang
,
target_sample_rate
,
wav_base64
=
tts_engine
.
run
(
sentence
,
spk_id
,
speed
,
volume
,
sample_rate
,
save_path
,
audio_format
)
#tts_engine.postprocess()
json_body
=
{
"success"
:
True
,
"code"
:
0
,
"message"
:
{
"description"
:
"success"
},
"result"
:
{
"lang"
:
lang
,
"spk_id"
:
spk_id
,
"speed"
:
speed
,
"volume"
:
volume
,
"sample_rate"
:
target_sample_rate
,
"save_path"
:
save_path
,
"audio"
:
wav_base64
}
}
return
json_body
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录