Spaces:
Sleeping
Sleeping
from flask import Flask, request, jsonify | |
from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq | |
from transformers import pipeline | |
app = Flask(__name__) | |
model = AutoModelForSpeechSeq2Seq.from_pretrained("GitNazarov/whisper-small-pt-3-uz") | |
processor = AutoProcessor.from_pretrained("GitNazarov/whisper-small-pt-3-uz") | |
def index(): | |
return jsonify({"message": "Welcome to whisper uz!"}) | |
def transcribe(): | |
data = request.json['data'] | |
inputs = processor(data, return_tensors="pt", sampling_rate=16000, max_new_tokens=100) | |
input_features = inputs.input_features | |
generated_ids = model.generate(inputs=input_features) | |
transcription = processor.batch_decode(generated_ids, skip_special_tokens=True) | |
transcription = ''.join(transcription) | |
return str(transcription), {'Content-Type': 'application/json'} | |
if __name__ == '__main__': | |
app.run(host='0.0.0.0', port=7860) |