Skip to content

Commit f74570c

Browse files
committed
fix mute pcm problem
1 parent 3060a85 commit f74570c

3 files changed

Lines changed: 33 additions & 10 deletions

File tree

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ RUN python download_model.py && \
2121
cd FunASR && \
2222
pip install -e ./
2323

24-
WORKDIR /home/funasr
24+
WORKDIR /home/funasr
25+
26+
ENV HTTP_PROXY=""
27+
ENV HTTPS_PROXY=""

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ services:
66
dockerfile: Dockerfile
77
args:
88
HTTP_PROXY: ${HTTP_PROXY}
9-
image: paidax/funasr_python:0.4.2
9+
image: paidax/funasr_python:0.4.4
1010
runtime: nvidia
1111
ports:
1212
- 9527:9527
13-
command: tail -f /dev/null
13+
command: uvicorn main:app --host 0.0.0.0 --port 9527

main.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,37 @@ async def predict(items: Audio):
9999
decoded_data = requests.get(items.file).content
100100

101101
load_model(model_type="long", hotword=items.hotword)
102-
rec_result = loaded_model["model"](audio_in=decoded_data)
103102
result = []
104-
log.info(rec_result)
105-
for sentence in rec_result["sentences"]:
103+
try:
104+
rec_result = loaded_model["model"](audio_in=decoded_data)
105+
log.info(rec_result)
106+
except:
107+
result.append(
108+
{
109+
"text": "",
110+
"start": 0.0,
111+
"end": 0.0
112+
}
113+
)
114+
log.info("pass small file")
115+
try:
116+
for sentence in rec_result["sentences"]:
117+
result.append(
118+
{
119+
"text": sentence["text"],
120+
"start": sentence["start"] / 1000.0,
121+
"end": sentence["end"] / 1000.0
122+
}
123+
)
124+
except:
106125
result.append(
107126
{
108-
"text": sentence["text"],
109-
"start": sentence["start"] / 1000.0,
110-
"end": sentence["end"] / 1000.0
127+
"text": "",
128+
"start": 0.0,
129+
"end": 0.0
111130
}
112131
)
132+
log.info("mute file")
113133
log.info(result)
114134
return result
115135

@@ -125,7 +145,7 @@ async def health_check():
125145
@app.get("/health/inference")
126146
async def health_check():
127147
try:
128-
load_model(model_type="normal", hotword=None)
148+
load_model(model_type="long", hotword=None)
129149
rec_result = loaded_model["model"](audio_in="./16000_001.wav")
130150
log.info("health 200")
131151
return status.HTTP_200_OK

0 commit comments

Comments
 (0)