Skip to main content

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、PortYes":8000,:8001"
vendor.vendor_id服務名稱YesTTS
vendor.vendor_id.action_ack_timeout
vendor.vendor_id.short_command_recog_timeoutNo8s
vendor.vendor_id.keep_duration產生語音檔儲存時長No3d
vendor.vendor_id.save_voice_file是否要儲存產生語音檔Yestrue
vendor.vendor_id.save_folder儲存資料夾位置Yes./voc
vendor.vendor_id.record_duration寫入紀錄前等待時間Yes30m
vendor.service_id供應商名稱YesAzure
vendor.service_id.vendor_id.key服務所需keyYesAPI_KEY
vendor.service_id.vendor_id.region服務所在區域Yeseastasia
vendor.service_id.vendor_id.recognized_timeout服務設定超時時間Yes
vendor.service_id.vendor_id.params服務所需參數Yes
vendor.service_id.vendor_id.patternNo
tenant_id.vendor_id.value指定租戶使用服務YesAzure
tenant_id.route_code指定租戶codeNo
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"

部署

systemctl start STMesh.service
systemctl enable STMesh.service
  • 使用Telnet確定服務狀況
!#bin/bash