Skip to content

Commit 9a0d91a

Browse files
authored
Enhance asr/tts tests (opea-project#952)
* add tests * validate tests * refactor log
1 parent 145f3fb commit 9a0d91a

File tree

4 files changed

+200
-2
lines changed

4 files changed

+200
-2
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
# Copyright (C) 2024 Intel Corporation
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
set -x
6+
7+
WORKPATH=$(dirname "$PWD")
8+
ip_address=$(hostname -I | awk '{print $1}')
9+
10+
function build_docker_images() {
11+
cd $WORKPATH
12+
echo $(pwd)
13+
docker build --no-cache -t opea/whisper-gaudi:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/asr/whisper/dependency/Dockerfile.intel_hpu .
14+
15+
if [ $? -ne 0 ]; then
16+
echo "opea/whisper-gaudi built fail"
17+
exit 1
18+
else
19+
echo "opea/whisper-gaudi built successful"
20+
fi
21+
22+
docker build --no-cache -t opea/asr:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/asr/whisper/Dockerfile .
23+
24+
if [ $? -ne 0 ]; then
25+
echo "opea/asr built fail"
26+
exit 1
27+
else
28+
echo "opea/asr built successful"
29+
fi
30+
}
31+
32+
function start_service() {
33+
unset http_proxy
34+
docker run -d --name="test-comps-asr-whisper-gaudi" --runtime=habana -e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none --cap-add=sys_nice -e http_proxy=$http_proxy -e https_proxy=$https_proxy -p 7066:7066 --ipc=host opea/whisper-gaudi:comps
35+
docker run -d --name="test-comps-asr" -e ASR_ENDPOINT=http://$ip_address:7066 -e http_proxy=$http_proxy -e https_proxy=$https_proxy -p 9089:9099 --ipc=host opea/asr:comps
36+
sleep 2m
37+
}
38+
39+
function validate_microservice() {
40+
result=$(http_proxy="" curl http://localhost:9089/v1/audio/transcriptions -XPOST -d '{"byte_str": "UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"}' -H 'Content-Type: application/json')
41+
if [[ $result == *"you"* ]]; then
42+
echo "Result correct."
43+
else
44+
echo "Result wrong."
45+
docker logs test-comps-asr-whisper
46+
docker logs test-comps-asr
47+
exit 1
48+
fi
49+
50+
}
51+
52+
function stop_docker() {
53+
cid=$(docker ps -aq --filter "name=test-comps-asr*")
54+
if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi
55+
}
56+
57+
function main() {
58+
59+
stop_docker
60+
61+
build_docker_images
62+
start_service
63+
64+
validate_microservice
65+
66+
stop_docker
67+
echo y | docker system prune
68+
69+
}
70+
71+
main

tests/tts/test_gpt_sovits.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
# Copyright (C) 2024 Intel Corporation
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
set -x
6+
7+
WORKPATH=$(dirname "$PWD")
8+
ip_address=$(hostname -I | awk '{print $1}')
9+
10+
function build_docker_images() {
11+
cd $WORKPATH
12+
echo $(pwd)
13+
docker build --no-cache --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -t opea/gpt-sovits:comps -f comps/tts/gpt-sovits/Dockerfile .
14+
if [ $? -ne 0 ]; then
15+
echo "opea/gpt-sovits built fail"
16+
exit 1
17+
else
18+
echo "opea/gpt-sovits built successful"
19+
fi
20+
}
21+
22+
function start_service() {
23+
unset http_proxy
24+
docker run -d --name="test-comps-gpt-sovits" -e http_proxy=$http_proxy -e https_proxy=$https_proxy -p 9880:9880 --ipc=host opea/gpt-sovits:comps
25+
sleep 2m
26+
}
27+
28+
function validate_microservice() {
29+
http_proxy="" curl http://localhost:9880/v1/audio/speech -XPOST -d '{"input":"你好呀,你是谁. Hello, who are you?"}' -H 'Content-Type: application/json' --output speech.mp3
30+
file_size=$(stat --format="%s" speech.mp3)
31+
if [[ $file_size -gt 0 ]]; then
32+
echo "Result correct."
33+
else
34+
echo "Result wrong."
35+
docker logs test-comps-gpt-sovits
36+
exit 1
37+
fi
38+
}
39+
40+
function stop_docker() {
41+
cid=$(docker ps -aq --filter "name=test-comps-gpt-sovits*")
42+
if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi
43+
}
44+
45+
function main() {
46+
47+
stop_docker
48+
49+
build_docker_images
50+
start_service
51+
52+
validate_microservice
53+
54+
stop_docker
55+
echo y | docker system prune
56+
57+
}
58+
59+
main

tests/tts/test_tts_speecht5.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ ip_address=$(hostname -I | awk '{print $1}')
1010
function build_docker_images() {
1111
cd $WORKPATH
1212
echo $(pwd)
13-
docker build --no-cache -t opea/speecht5:comps -f comps/tts/speecht5/dependency/Dockerfile .
13+
docker build --no-cache --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -t opea/speecht5:comps -f comps/tts/speecht5/dependency/Dockerfile .
1414
if [ $? -ne 0 ]; then
1515
echo "opea/speecht5 built fail"
1616
exit 1
1717
else
1818
echo "opea/speecht5 built successful"
1919
fi
20-
docker build --no-cache -t opea/tts:comps -f comps/tts/speecht5/Dockerfile .
20+
docker build --no-cache --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -t opea/tts:comps -f comps/tts/speecht5/Dockerfile .
2121
if [ $? -ne 0 ]; then
2222
echo "opea/tts built fail"
2323
exit 1
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
# Copyright (C) 2024 Intel Corporation
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
set -x
6+
7+
WORKPATH=$(dirname "$PWD")
8+
ip_address=$(hostname -I | awk '{print $1}')
9+
10+
function build_docker_images() {
11+
cd $WORKPATH
12+
echo $(pwd)
13+
docker build --no-cache --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -t opea/speecht5-gaudi:comps -f comps/tts/speecht5/dependency/Dockerfile.intel_hpu .
14+
if [ $? -ne 0 ]; then
15+
echo "opea/speecht5-gaudi built fail"
16+
exit 1
17+
else
18+
echo "opea/speecht5-gaudi built successful"
19+
fi
20+
docker build --no-cache --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -t opea/tts:comps -f comps/tts/speecht5/Dockerfile .
21+
if [ $? -ne 0 ]; then
22+
echo "opea/tts built fail"
23+
exit 1
24+
else
25+
echo "opea/tts built successful"
26+
fi
27+
}
28+
29+
function start_service() {
30+
unset http_proxy
31+
docker run -d --name="test-comps-tts-speecht5" --runtime=habana -e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none --cap-add=sys_nice -e http_proxy=$http_proxy -e https_proxy=$https_proxy -p 5017:7055 --ipc=host opea/speecht5-gaudi:comps
32+
docker run -d --name="test-comps-tts" -e TTS_ENDPOINT=http://$ip_address:5017 -e http_proxy=$http_proxy -e https_proxy=$https_proxy -p 5016:9088 --ipc=host opea/tts:comps
33+
sleep 3m
34+
}
35+
36+
function validate_microservice() {
37+
result=$(http_proxy="" curl http://localhost:5016/v1/audio/speech -XPOST -d '{"text": "Who are you?"}' -H 'Content-Type: application/json')
38+
if [[ $result == *"Ukl"* ]]; then
39+
echo "Result correct."
40+
else
41+
echo "Result wrong."
42+
docker logs test-comps-tts-speecht5
43+
docker logs test-comps-tts
44+
exit 1
45+
fi
46+
47+
}
48+
49+
function stop_docker() {
50+
cid=$(docker ps -aq --filter "name=test-comps-tts*")
51+
if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi
52+
}
53+
54+
function main() {
55+
56+
stop_docker
57+
58+
build_docker_images
59+
start_service
60+
61+
validate_microservice
62+
63+
stop_docker
64+
echo y | docker system prune
65+
66+
}
67+
68+
main

0 commit comments

Comments
 (0)