STMesh部署
為了讓各位不要用tmux來部署系統層級的服務,還有讓未來有跡可循
相依套件
資料夾
.
|-- STMesh
| |-- STMesh(執行檔)
| |-- config.yaml (設定檔)
| |-- logs(紀錄)
| | |-- debug
| | |-- error
| | |-- info
| | `-- interaction
| `-- voc
| `-- records.json
`-- speechsdk (Microsoft Azure Speech Service SDK)
|-- LICENSE.md
|-- REDIST.txt
|-- ThirdPartyNotices.md
|-- include
| |-- c_api
| `-- cxx_api
`-- lib
|-- arm32
|-- arm64
|-- centos7-x64
`-- x64
設置
環境參數
export SPEECHSDK_ROOT="Absolute path where it belongs"
export CGO_CFLAGS="-I$SPEECHSDK_ROOT/include/c_api"
export CGO_LDFLAGS="-L$SPEECHSDK_ROOT/lib/x64 -lMicrosoft.CognitiveServices.Speech.core"
export LD_LIBRARY_PATH="$SPEECHSDK_ROOT/lib/x64:$LD_LIBRARY_PATH"
STMesh設定 (由YAML檔註解翻譯)
| 鍵值 | 描述 | 必填與否 | 範例值 |
|---|---|---|---|
| server.address | 服務監聽IP、Port | Yes | ":8000,:8001" |
| vendor.vendor_id | 服務名稱 | Yes | TTS |
| vendor.vendor_id.action_ack_timeout | |||
| vendor.vendor_id.short_command_recog_timeout | No | 8s | |
| vendor.vendor_id.keep_duration | 產生語音檔儲存時長 | No | 3d |
| vendor.vendor_id.save_voice_file | 是否要儲存產生語音檔 | Yes | true |
| vendor.vendor_id.save_folder | 儲存資料夾位置 | Yes | ./voc |
| vendor.vendor_id.record_duration | 寫入紀錄前等待時間 | Yes | 30m |
| vendor.service_id | 供應商名稱 | Yes | Azure |
| vendor.service_id.vendor_id.key | 服務所需key | Yes | API_KEY |
| vendor.service_id.vendor_id.region | 服務所在區域 | Yes | eastasia |
| vendor.service_id.vendor_id.recognized_timeout | 服務設定超時時間 | Yes | |
| vendor.service_id.vendor_id.params | 服務所需參數 | Yes | |
| vendor.service_id.vendor_id.pattern | No | ||
| tenant_id.vendor_id.value | 指定租戶使用服務 | Yes | Azure |
| tenant_id.route_code | 指定租戶code | No |
server:
address: ":8000,:8001"
openapiPath: "/api.json"
swaggerPath: "/swagger"
clientMaxBodySize: 100m
pprofEnabled: false
logger:
level: "all"
stdout: true
path: "./logs"
file:
rotateBackupLimit: 3
rotateBackupExpire: "3d"
rotateBackupCompress: 9
websocket:
hand_shake_timeout: 45s
# Define Vendor->Vendor ID->Service->Service Parameters
vendor:
STT:
action_ack_timeout: 6m
# The timeout period for short command recognition is currently applicable to the stt recognition short command under Azure.
short_command_recog_timeout: 8s
save_voice_buffer: false
save_folder: ./buf
TTS:
# timeout for performing speech synthesis
action_ack_timeout: 1m
# The time interval between writing records to the file
record_duration: 30m
# how long the generated files are retained
keep_duration: 3d
# whether to save the generated voice file
save_voice_file: true
# file save location
save_folder: ./voc
Azure:
STT:
key: "f8506cbed78841ab9396c40a88c97f5f"
region: "eastasia"
recognized_timeout: 30s
params: |
{
"language": "zh-TW"
}
TTS:
key: "f8506cbed78841ab9396c40a88c97f5f"
region: "eastasia"
params: |
{
"language": "zh-TW",
"type": "wav",
"speaker" : "zh-TW-HsiaoChenNeural",
"speed": "default" ,
"volume": "default",
"pitch": "default"
}
pattern: |
<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="$language">
<voice name="$speaker" >
<prosody rate="$speed" volume="$volume" pitch="$pitch">
%s
</prosody>
</voice>
</speak>
Cyberon:
TTS:
http:
url: "61.222.43.4:28889"
params: |
{
"serviceName": "e2e",
"outfmt": "wav",
"vbr_quality": 4,
"language": "zh-TW",
"phrbrk": false,
"speaker": "Sharon",
"speed": 1,
"gain": 1,
"token": "2B0aWlQu8V1OX0YragC1t5prfNVDzL4OndyjLDIGED4JotQ8F5djueIKn_NfIg7Rxop5tdkYgCr-H3-SeVTB6ykrH1azXdrpJucXVNUdgM_bSwD-qqaHJzXr9tLf7AvR"
}
STT:
ws_recognize_file:
start_params: |
{
"domain":"freeSTT-zh-TW",
"platform":"web",
"token":"2B0aWlQu8V1OX0YragC1t5prfNVDzL4OndyjLDIGED4JotQ8F5djueIKn_NfIg7Rxop5tdkYgCr-H3-SeVTB6ykrH1azXdrpJucXVNUdgM_bSwD-qqaHJzXr9tLf7AvR",
"nBestNum": 1,
"bIsDoEPD": true ,
"bIsDoPR": true,
"type":"audio/wav;rate=16000"
}
http:
url: ""
ws:
url: "ws://61.222.43.4:28888"
start_params: |
{
"domain":"freeSTT-zh-TW",
"platform":"web",
"token":"2B0aWlQu8V1OX0YragC1t5prfNVDzL4OndyjLDIGED4JotQ8F5djueIKn_NfIg7Rxop5tdkYgCr-H3-SeVTB6ykrH1azXdrpJucXVNUdgM_bSwD-qqaHJzXr9tLf7AvR",
"nBestNum": 1,
"bIsDoEPD": true ,
"bIsDoPR": true,
"type":"audio/L16;rate=16000"
}
EmotiBot:
TTS:
http:
url: "http://61.222.43.4:18200/tts"
params: |
{
"language": "zh-tw",
"speed": 6,
"volume": 3 ,
"pitch" : 5,
"type": "wav",
"samplerate": 8000
}
STT:
http:
url: "http://61.222.43.4:18000/client/dynamic/recognize"
params: |
{
"sample-rate": 16000,
"do-punctuation": true,
"auto-digit-convert": true
}
ws_recognize_file:
# identify files using web socket method
url: "ws://61.222.43.4:18000/client/ws/recognize"
voc_format: |
{
"sample_rate": 16000,
"bit_per_sample":16 ,
"channels": 1 ,
"duration": 100,
}
params: "?sample-rate=16000&do-punctuation=true&auto-digit-convert=true"
ws:
url: "ws://61.222.43.4:18000/client/ws/voice"
start_params: |
{
"message":{
"type":"INIT"
},
"service":["recognize"],
"service_params": {
"recognize":{
"enable_partial": false
}
},
"session":{
"sample-rate":16000
},
"token":"default"
}
# Tenant id -> route access code (optional) -> service -> manufacturer
default:
STT: Azure
TTS: Azure
default_111111:
STT: Azure
TTS: Azure
tenant_111111:
rac_000:
STT: Azure
TTS: Azure
服務檔內容
id="systemd-content"
[Unit]
Description=STMesh daemon service
Wants=network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
ExecStart=./STMesh
Restart=always
RestartSec=5
User=stmesh
Group=stmesh
WorkingDirectory=/home/stmesh
Environment="SPEECHSDK_ROOT=/home/stmesh/speechsdk"
Environment="CGO_CFLAGS=-I$SPEECHSDK_ROOT/include/c_api"
Environment="CGO_LDFLAGS=-L$SPEECHSDK_ROOT/lib/x64 -lMicrosoft.CognitiveServices.Speech.core"
Environment="LD_LIBRARY_PATH=$SPEECHSDK_ROOT/lib/x64:$LD_LIBRARY_PATH"
部署
- 取得STMesh (@Wilson)
- 安裝Microsoft Azure Speech SDK
安裝tmux(Please don't)- 新增服務 參考上面的服務檔內容
- 啟動服務
systemctl start STMesh.service
systemctl enable STMesh.service
- 使用Telnet確定服務狀況
!#bin/bash