Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
add whisper example (#114)
Browse files Browse the repository at this point in the history
Signed-off-by: intellinjun <[email protected]>
  • Loading branch information
intellinjun authored Feb 4, 2024
1 parent 90f5cbd commit c97dbe0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions neural_speed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def init(self, model_name, use_quant=True, use_gptq=False, use_awq=False,
scale_dtype="fp32", compute_dtype="int8", use_ggml=False):
self.config = AutoConfig.from_pretrained(model_name, trust_remote_code=True)
model_type = Model.get_model_type(self.config)
self.model_type = model_type
self.__import_package(model_type)

# check cache and quantization
Expand Down
28 changes: 28 additions & 0 deletions scripts/whisper_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
from transformers import AutoTokenizer, TextStreamer
from neural_speed import Model

if len(sys.argv) != 3:
print("Usage: python whisper_example.py model_path and audio_file")
model_name = sys.argv[1]
audio_file = sys.argv[2]

model = Model()
model.init(model_name, use_ggml=True)
model(audio_file)

0 comments on commit c97dbe0

Please sign in to comment.