Skip to content

Commit

Permalink
Enhance asr/tts tests (opea-project#952)
Browse files Browse the repository at this point in the history
* add tests

* validate tests

* refactor log
  • Loading branch information
Spycsh authored Nov 28, 2024
1 parent 145f3fb commit 9a0d91a
Show file tree
Hide file tree
Showing 4 changed files with 200 additions and 2 deletions.
71 changes: 71 additions & 0 deletions tests/asr/test_asr_whisper_on_intel_hpu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

set -x

WORKPATH=$(dirname "$PWD")
ip_address=$(hostname -I | awk '{print $1}')

function build_docker_images() {
cd $WORKPATH
echo $(pwd)
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 .

if [ $? -ne 0 ]; then
echo "opea/whisper-gaudi built fail"
exit 1
else
echo "opea/whisper-gaudi built successful"
fi

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 .

if [ $? -ne 0 ]; then
echo "opea/asr built fail"
exit 1
else
echo "opea/asr built successful"
fi
}

function start_service() {
unset http_proxy
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
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
sleep 2m
}

function validate_microservice() {
result=$(http_proxy="" curl http://localhost:9089/v1/audio/transcriptions -XPOST -d '{"byte_str": "UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"}' -H 'Content-Type: application/json')
if [[ $result == *"you"* ]]; then
echo "Result correct."
else
echo "Result wrong."
docker logs test-comps-asr-whisper
docker logs test-comps-asr
exit 1
fi

}

function stop_docker() {
cid=$(docker ps -aq --filter "name=test-comps-asr*")
if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi
}

function main() {

stop_docker

build_docker_images
start_service

validate_microservice

stop_docker
echo y | docker system prune

}

main
59 changes: 59 additions & 0 deletions tests/tts/test_gpt_sovits.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

set -x

WORKPATH=$(dirname "$PWD")
ip_address=$(hostname -I | awk '{print $1}')

function build_docker_images() {
cd $WORKPATH
echo $(pwd)
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 .
if [ $? -ne 0 ]; then
echo "opea/gpt-sovits built fail"
exit 1
else
echo "opea/gpt-sovits built successful"
fi
}

function start_service() {
unset http_proxy
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
sleep 2m
}

function validate_microservice() {
http_proxy="" curl http://localhost:9880/v1/audio/speech -XPOST -d '{"input":"你好呀,你是谁. Hello, who are you?"}' -H 'Content-Type: application/json' --output speech.mp3
file_size=$(stat --format="%s" speech.mp3)
if [[ $file_size -gt 0 ]]; then
echo "Result correct."
else
echo "Result wrong."
docker logs test-comps-gpt-sovits
exit 1
fi
}

function stop_docker() {
cid=$(docker ps -aq --filter "name=test-comps-gpt-sovits*")
if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi
}

function main() {

stop_docker

build_docker_images
start_service

validate_microservice

stop_docker
echo y | docker system prune

}

main
4 changes: 2 additions & 2 deletions tests/tts/test_tts_speecht5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ ip_address=$(hostname -I | awk '{print $1}')
function build_docker_images() {
cd $WORKPATH
echo $(pwd)
docker build --no-cache -t opea/speecht5:comps -f comps/tts/speecht5/dependency/Dockerfile .
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 .
if [ $? -ne 0 ]; then
echo "opea/speecht5 built fail"
exit 1
else
echo "opea/speecht5 built successful"
fi
docker build --no-cache -t opea/tts:comps -f comps/tts/speecht5/Dockerfile .
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 .
if [ $? -ne 0 ]; then
echo "opea/tts built fail"
exit 1
Expand Down
68 changes: 68 additions & 0 deletions tests/tts/test_tts_speecht5_on_intel_hpu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

set -x

WORKPATH=$(dirname "$PWD")
ip_address=$(hostname -I | awk '{print $1}')

function build_docker_images() {
cd $WORKPATH
echo $(pwd)
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 .
if [ $? -ne 0 ]; then
echo "opea/speecht5-gaudi built fail"
exit 1
else
echo "opea/speecht5-gaudi built successful"
fi
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 .
if [ $? -ne 0 ]; then
echo "opea/tts built fail"
exit 1
else
echo "opea/tts built successful"
fi
}

function start_service() {
unset http_proxy
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
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
sleep 3m
}

function validate_microservice() {
result=$(http_proxy="" curl http://localhost:5016/v1/audio/speech -XPOST -d '{"text": "Who are you?"}' -H 'Content-Type: application/json')
if [[ $result == *"Ukl"* ]]; then
echo "Result correct."
else
echo "Result wrong."
docker logs test-comps-tts-speecht5
docker logs test-comps-tts
exit 1
fi

}

function stop_docker() {
cid=$(docker ps -aq --filter "name=test-comps-tts*")
if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi
}

function main() {

stop_docker

build_docker_images
start_service

validate_microservice

stop_docker
echo y | docker system prune

}

main

0 comments on commit 9a0d91a

Please sign in to comment.