-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add asr/tts components for xeon and hpu (#222)
* add asr/tts component for xeon and hpu Signed-off-by: Spycsh <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix * fix * fix ffmpeg JSONDecode error on HPU * add tests * trigger * try --------- Signed-off-by: Spycsh <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
fe5f394
commit cef6eac
Showing
23 changed files
with
792 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import base64 | ||
import json | ||
import os | ||
import urllib.request | ||
import uuid | ||
from io import BytesIO | ||
|
||
import requests | ||
|
||
# https://gist.github.com/novwhisky/8a1a0168b94f3b6abfaa | ||
# test_audio_base64_str = "UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA" | ||
|
||
uid = str(uuid.uuid4()) | ||
file_name = uid + ".wav" | ||
|
||
urllib.request.urlretrieve( | ||
"https://github.com/intel/intel-extension-for-transformers/raw/main/intel_extension_for_transformers/neural_chat/assets/audio/sample.wav", | ||
file_name, | ||
) | ||
|
||
with open(file_name, "rb") as f: | ||
test_audio_base64_str = base64.b64encode(f.read()).decode("utf-8") | ||
os.remove(file_name) | ||
|
||
endpoint = "http://localhost:9099/v1/audio/transcriptions" | ||
inputs = {"byte_str": test_audio_base64_str} | ||
response = requests.post(url=endpoint, data=json.dumps(inputs), proxies={"http": None}) | ||
print(response.json()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
FROM python:3.11-slim | ||
|
||
# Set environment variables | ||
ENV LANG=en_US.UTF-8 | ||
ENV PYTHONPATH=/home/user | ||
|
||
# Install system dependencies | ||
RUN apt-get update \ | ||
&& apt-get install -y ffmpeg | ||
|
||
COPY comps /home/comps | ||
|
||
RUN pip install --no-cache-dir --upgrade pip && \ | ||
pip install --no-cache-dir -r /home/comps/asr/requirements.txt | ||
|
||
ENV PYTHONPATH=$PYTHONPATH:/home | ||
|
||
WORKDIR /home/comps/asr/whisper | ||
|
||
ENTRYPOINT ["python", "whisper_server.py", "--device", "cpu"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# HABANA environment | ||
FROM vault.habana.ai/gaudi-docker/1.14.0/ubuntu22.04/habanalabs/pytorch-installer-2.1.1 AS hpu | ||
|
||
# Set environment variables | ||
ENV LANG=en_US.UTF-8 | ||
ENV PYTHONPATH=/home/user:/usr/lib/habanalabs/:/optimum-habana | ||
|
||
# Install system dependencies | ||
RUN apt-get update \ | ||
&& apt-get install -y ffmpeg | ||
|
||
COPY comps /home/comps | ||
|
||
# Install requirements and optimum habana | ||
RUN pip install --no-cache-dir --upgrade pip && \ | ||
pip install --no-cache-dir -r /home/comps/asr/requirements.txt && \ | ||
pip install optimum[habana] | ||
|
||
ENV PYTHONPATH=$PYTHONPATH:/home | ||
|
||
WORKDIR /home/comps/asr/whisper | ||
|
||
ENTRYPOINT ["python", "whisper_server.py", "--device", "hpu"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import base64 | ||
import json | ||
import os | ||
import urllib.request | ||
import uuid | ||
from io import BytesIO | ||
|
||
import requests | ||
|
||
# https://gist.github.com/novwhisky/8a1a0168b94f3b6abfaa | ||
# test_audio_base64_str = "UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA" | ||
|
||
uid = str(uuid.uuid4()) | ||
file_name = uid + ".wav" | ||
|
||
urllib.request.urlretrieve( | ||
"https://github.com/intel/intel-extension-for-transformers/raw/main/intel_extension_for_transformers/neural_chat/assets/audio/sample.wav", | ||
file_name, | ||
) | ||
|
||
with open(file_name, "rb") as f: | ||
test_audio_base64_str = base64.b64encode(f.read()).decode("utf-8") | ||
os.remove(file_name) | ||
|
||
endpoint = "http://localhost:7066/v1/asr" | ||
inputs = {"audio": test_audio_base64_str} | ||
response = requests.post(url=endpoint, data=json.dumps(inputs), proxies={"http": None}) | ||
print(response.json()) |
Oops, something went wrong.