Skip to content

Commit 09a10e9

Browse files
committed
support .pcm
1 parent c4e5972 commit 09a10e9

2 files changed

Lines changed: 1 addition & 24 deletions

File tree

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
build:
55
context: .
66
dockerfile: Dockerfile
7-
image: paidax/funasr_python:0.3
7+
image: paidax/funasr_python:0.3.1
88
runtime: nvidia
99
ports:
1010
- 9527:9527

main.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -72,28 +72,6 @@ def load_model(model_type, hotword):
7272
if loaded_model["model_type"] is None or loaded_model["model_type"] != model_type or (loaded_model["model_type"] == "hotword" and hotword_parm["hotword"] != hotword):
7373
loaded_model["model"] = initialize_model(model_type, hotword)
7474

75-
def convert_audio_to_wav(binary_data):
76-
byte_stream = io.BytesIO(binary_data)
77-
formats = ['mp3', 'wav', 'ogg', 'flv', 'mp4', 'aac']
78-
audio = None
79-
for format in formats:
80-
byte_stream.seek(0) # reset byte stream position
81-
try:
82-
audio = AudioSegment.from_file(byte_stream, format=format)
83-
break
84-
except:
85-
pass
86-
if audio is None:
87-
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST)
88-
if audio.channels > 1:
89-
audio = audio.set_channels(1)
90-
audio = audio.set_frame_rate(16000)
91-
buffer = io.BytesIO()
92-
audio.export(buffer, format='wav')
93-
binary_data_resampled = buffer.getvalue()
94-
95-
return binary_data_resampled
96-
9775

9876
@app.post("/asr", tags=["ASR"], summary="聚合ASR模型接口服务")
9977
async def predict(items: Audio):
@@ -115,7 +93,6 @@ async def predict(items: Audio):
11593
log.info(f"Received a url in string, url: {items.file}")
11694
decoded_data = requests.get(items.file).content
11795

118-
decoded_data = convert_audio_to_wav(decoded_data)
11996
load_model(model_type=items.model_type, hotword=items.hotword)
12097
rec_result = loaded_model["model"](audio_in=decoded_data)
12198
if items.model_type=='normal' or items.model_type=='long':

0 commit comments

Comments
 (0)