unimrcp 语音服务 直接部署 和 docker 构建安装
·
unimrcp直接部署
# 官网
https://www.unimrcp.org/index.php/solutions/server
https://github.com/unispeech/unimrcp/blob/master/INSTALL
# 安装依赖
# 下载 unimrcp-deps-1.6.0
cd /opt
https://www.unimrcp.org/project/release-view/unimrcp-deps-1-6-0-tar-gz/download
# 解压
gzip -d unimrcp-deps-1.6.0.tar.gz
tar -xvf unimrcp-1.8.0.tar
cd /opt/unimrcp-deps-1.6.0
# 安装依赖项 ./build-dep-libs.sh 未知原因脚本不好用
# 有时会出现 apr-util安装失败或 运行unimrcp出现apr_pool_mutex_set 函数不存在的问题
# 需要手动安装
# apr
cd /opt/unimrcp-deps-1.6.0/libs/apr
./configure --prefix=/usr/local/apr
make
sudo make install
# apr-util
cd /opt/unimrcp-deps-1.6.0/libs/apr-util
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make
sudo make install
# sofia-sip
cd /opt/unimrcp-deps-1.6.0/libs/sofia-sip
./configure --prefix=/usr
make
sudo make install
# 验证函数
nm -D /usr/local/apr/lib/libapr-1.so | grep apr_pool_mutex_set
# 下载 unimrcp-1.8.0
cd /opt
https://www.unimrcp.org/project/component-view/unimrcp-1-8-0-tar-gz/download
# 解压
gzip -d unimrcp-1.8.0.tar.gz
tar -xvf unimrcp-1.8.0.tar
# 执行以下脚本来构建并安装依赖项
cd /opt/unimrcp-1.8.0
./bootstrap
./configure --with-apr-util=/usr/local/apr-util --with-apr=/usr/local/apr --with-sofia-sip=/usr
# 出现以下内容为编译成功,否则删除 apr apr-util sofia-sp 重新安装
#****************************** REPORT ******************************
#
#UniMRCP version............... : 1.8.0
#
#APR version................... : 1.5.2
#APR-util version.............. : 1.5.4
#Sofia-SIP version............. : 1.12.11-239-g54ef3e2
#
#Compiler...................... : gcc
#Compiler flags................ : -g -O2 -pthread
#Preprocessor definitions...... : -DLINUX -D_REENTRANT -D_GNU_SOURCE
#Linker flags.................. :
#
#UniMRCP client lib............ : yes
#Sample UniMRCP client app..... : yes
#Sample UMC C++ client app..... : yes
#Misc ASR client lib and app... : yes
#
#UniMRCP server lib............ : yes
#UniMRCP server app............ : yes
#
#Demo synthesizer plugin....... : yes
#Demo recognizer plugin........ : yes
#Demo verifier plugin.......... : yes
#Recorder plugin............... : yes
#
#Installation layout........... : classic
#Installation directory........ : /usr/local/unimrcp
#
#********************************************************************
make
sudo make install
# 安装后 unimcp服务 位置 /usr/local/unimrcp/bin
cd /usr/local/unimrcp/bin
# 测试运行
./unimrcpserver
# 出现 [NOTICE] MRCP Server Started 为成功
# 如果运行 unimcp出现错误 ,需针对错误内容删除对应已安装的内容
# 重新手动安装apr apr-util sofia-sip 需执行 make clean
# 单独窗口 启动示例客户端
./umc
# 通过发出相应的指令,可以运行典型的语音合成、识别、录音和验证等场景。
# UniMRCP 客户端应用程序的控制台。对于语音合成,
# 使用:运行合成器对于语音识别,
run synth
# 使用:运行识别程序对于双音多频识别,
run recog
# 使用:运行 DTMF 功能对于语音记录器,
run dtmf
# 使用:运行记录对于语音验证,
run rec
# 使用:运行验证查看控制台输出,
run verify
# 检查是否存在任何可能的警告或错误。请注意,合成语音和录制的语音会存储在数据目录中。
# 此外,要留意默认加载到 UniMRCP 服务器中的演示插件。它们只是纯粹的模拟器。
# 这些插件仅是为演示目的而开发的。
# 设置使用systemctl进行管理服务
vi /etc/systemd/system/unimrcp-server.service
# 输入一下内容
[Unit]
Description=UniMRCP Server
After=network.target
[Service]
Type=simple
# 替换为实际的 UniMRCP 服务器可执行文件路径
WorkingDirectory=/usr/local/unimrcp/bin
ExecStart=/usr/local/unimrcp/bin/unimrcpserver
Restart=on-failure
RestartSec=10s
User=root
Group=root
[Install]
WantedBy=multi-user.target
# 重新加载 systemd 配置
sudo systemctl daemon-reload
# 启动服务
sudo systemctl start unimrcp-server
# 停止服务
sudo systemctl stop unimrcp-server
# 重启服务
sudo systemctl restart unimrcp-server
# 查看服务状态
sudo systemctl status unimrcp-server
# 状态显示 active (running) 表示服务正常运行。
# 设置开机自启动
sudo systemctl enable unimrcp-server
# 禁用开机自启动
sudo systemctl disable unimrcp-server
unimrcp docekr构建记录
# docker镜像构建
# 拉取ubuntu镜像
docker pull ubuntu:20.04
# 运行一个交互式容器
docker run -it --name unimrcp-build ubuntu:20.04 /bin/sh
# 设置时区变量
export DEBIAN_FRONTEND=noninteractive
export TZ=Asia/Shanghai
# apt-get 安装基础命令
apt-get update && apt-get install -y \
git \
build-essential \
autoconf \
automake \
libtool \
pkg-config \
wget \
curl \
unzip \
libssl-dev \
libxml2-dev \
libsndfile1-dev \
sox \
wget \
gcc \
make \
g++
# 下载 unimrcp-deps.1.6.0
cd /opt
wget https://www.unimrcp.org/project/release-view/unimrcp-deps-1-6-0-tar-gz/download
mv download unimrcp-deps-1.6.0.tar.gz
# 解压
tar -zxvf unimrcp-deps-1.6.0.tar.gz
# 安装 apr apr-util spi
# apr
cd /opt/unimrcp-deps-1.6.0/libs/apr
./configure --prefix=/usr/local/apr
make
make install
# apr-util
cd /opt/unimrcp-deps-1.6.0/libs/apr-util
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make
make install
# sofia-sip
cd /opt/unimrcp-deps-1.6.0/libs/sofia-sip
./configure --prefix=/usr
make
make install
# 下载 unimrcp-1.8.0
cd /opt
wget https://www.unimrcp.org/project/component-view/unimrcp-1-8-0-tar-gz/download
mv download unimrcp-1.8.0.tar.gz
# 解压
tar -zxvf unimrcp-1.8.0.tar.gz
# 编译安装
cd /opt/unimrcp-1.8.0
./bootstrap
./configure --with-apr-util=/usr/local/apr-util --with-apr=/usr/local/apr --with-sofia-sip=/usr
# 出现一下内容为成功
# UniMRCP version............... : 1.8.0
# APR version................... : 1.5.2
# APR-util version.............. : 1.5.4
# Sofia-SIP version............. : 1.12.11-239-g54ef3e2
# 安装
make
make install
# 无报错即为成功,可在最终安装目录 /usr/local/unimrcp 验证
# 退出容器,将容器打包成镜像,查找容器 并打包
docker ps -a
docker commit ubuntu:20.04(自己的容器名称或id) unimrcp:1.8.0
# 导出镜像
docker save unimrcp:1.8.0 > /opt/unimrcp-1.8.0.tar
#或上传到docker仓库
unimrcpServer Dockerfile文件
# 使用Ubuntu 20.04作为基础镜像
FROM ubuntu:20.04
# 设置时区环境变量,避免交互式配置
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Shanghai
# 安装基础依赖包
RUN apt-get update && apt-get install -y \
git \
build-essential \
autoconf \
automake \
libtool \
pkg-config \
wget \
curl \
unzip \
libssl-dev \
libxml2-dev \
libsndfile1-dev \
sox \
gcc \
make \
g++ \
&& rm -rf /var/lib/apt/lists/* # 清理apt缓存,减小镜像体积
# 安装unimrcp-deps-1.6.0
WORKDIR /opt
RUN wget https://www.unimrcp.org/project/release-view/unimrcp-deps-1-6-0-tar-gz/download -O unimrcp-deps-1.6.0.tar.gz \
&& tar -zxvf unimrcp-deps-1.6.0.tar.gz \
&& rm unimrcp-deps-1.6.0.tar.gz # 解压后删除压缩包
# 编译安装apr
WORKDIR /opt/unimrcp-deps-1.6.0/libs/apr
RUN ./configure --prefix=/usr/local/apr \
&& make \
&& make install
# 编译安装apr-util
WORKDIR /opt/unimrcp-deps-1.6.0/libs/apr-util
RUN ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr \
&& make \
&& make install
# 编译安装sofia-sip
WORKDIR /opt/unimrcp-deps-1.6.0/libs/sofia-sip
RUN ./configure --prefix=/usr \
&& make \
&& make install
# 安装unimrcp-1.8.0
WORKDIR /opt
RUN wget https://www.unimrcp.org/project/component-view/unimrcp-1-8-0-tar-gz/download -O unimrcp-1.8.0.tar.gz \
&& tar -zxvf unimrcp-1.8.0.tar.gz \
&& rm unimrcp-1.8.0.tar.gz # 解压后删除压缩包
# 编译安装unimrcp
WORKDIR /opt/unimrcp-1.8.0
RUN ./bootstrap \
&& ./configure --with-apr-util=/usr/local/apr-util --with-apr=/usr/local/apr --with-sofia-sip=/usr \
&& make \
&& make install
# 设置工作目录为unimrcp安装目录
WORKDIR /usr/local/unimrcp/bin
# 容器启动时自动执行unimrcpserver
CMD ["./unimrcpserver"]
unimrcp 语音服务容器运行
# 在 Dockerfile目录下 运行
docker build -t unimrcp-server:1.8.0 .
# 启动容器 --net=host 容器直接使用主机的网络
docker run -d --net=host --restart=always --name my-unimrcp unimrcp-server:1.8.0
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)