cyberspyde commited on
Commit
06eaec7
1 Parent(s): 63bd0c7
Files changed (2) hide show
  1. Dockerfile +2 -0
  2. main.py +5 -2
Dockerfile CHANGED
@@ -8,6 +8,8 @@ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
 
9
  RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
10
 
 
 
11
  RUN apt-get -y update
12
 
13
  RUN useradd -m -u 1000 user
 
8
 
9
  RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
10
 
11
+ RUN pip install numpy
12
+
13
  RUN apt-get -y update
14
 
15
  RUN useradd -m -u 1000 user
main.py CHANGED
@@ -1,7 +1,8 @@
1
  from flask import Flask, request, jsonify
2
  from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq
3
  from transformers import pipeline
4
-
 
5
  app = Flask(__name__)
6
  model = AutoModelForSpeechSeq2Seq.from_pretrained("GitNazarov/whisper-small-pt-3-uz")
7
  processor = AutoProcessor.from_pretrained("GitNazarov/whisper-small-pt-3-uz")
@@ -13,7 +14,9 @@ def index():
13
  @app.route('/transcribe', methods=['POST'])
14
  def transcribe():
15
  data = request.json['data']
16
- inputs = processor(data, return_tensors="pt", sampling_rate=16000, max_new_tokens=100)
 
 
17
  input_features = inputs.input_features
18
  generated_ids = model.generate(inputs=input_features)
19
 
 
1
  from flask import Flask, request, jsonify
2
  from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq
3
  from transformers import pipeline
4
+ import numpy as np
5
+ import json
6
  app = Flask(__name__)
7
  model = AutoModelForSpeechSeq2Seq.from_pretrained("GitNazarov/whisper-small-pt-3-uz")
8
  processor = AutoProcessor.from_pretrained("GitNazarov/whisper-small-pt-3-uz")
 
14
  @app.route('/transcribe', methods=['POST'])
15
  def transcribe():
16
  data = request.json['data']
17
+ data = json.loads(data)
18
+ tensor_data = np.array(data)
19
+ inputs = processor(tensor_data, return_tensors="pt", sampling_rate=16000, max_new_tokens=100)
20
  input_features = inputs.input_features
21
  generated_ids = model.generate(inputs=input_features)
22