Commit 88281141 authored by Malsha Rathnasiri's avatar Malsha Rathnasiri

fix issues

parent 7108789d
venv/
backend/output.wav
backend/backend/output.m4a
ffmpeg-2022-08-03-git-d3f48e68b3-essentials_build/ffmpeg.exe
ngrok.exe
ffmpeg-2022-08-03-git-d3f48e68b3-essentials_build/ffplay.exe
ffmpeg-2022-08-03-git-d3f48e68b3-essentials_build/ffprobe.exe
......@@ -49,7 +49,7 @@ export const AudioRecorder = ({ setDetectedText }) => {
}
playSound(uri)
FileSystem.uploadAsync("https://1ec4-112-134-210-155.ap.ngrok.io/mlmodels/detect/", uri, { headers: headers, uploadType: FileSystem.FileSystemUploadType.MULTIPART })
FileSystem.uploadAsync("https://ebf4-2401-dd00-10-20-4ca2-920b-4150-8178.in.ngrok.io/mlmodels/detect/", uri, { headers: headers, uploadType: FileSystem.FileSystemUploadType.MULTIPART })
.then(data => JSON.parse(data.body))
.then(data => { console.log({ result: data }); setDetectedText(data.result); setTimeout(() => setDetectedText(''), 1000) })
.catch(err => console.log({ err }))
......
......@@ -20,17 +20,17 @@ def predict(samples):
all_label = pickle.load(f1)
print('loaded labels')
f2 = open('all_waves_file.txt', 'rb')
all_wave = pickle.load(f2)
print('loaded waves')
# f2 = open('all_waves_file.txt', 'rb')
# all_wave = pickle.load(f2)
# print('loaded waves')
le = LabelEncoder()
y = le.fit_transform(all_label)
classes = list(le.classes_)
train_data_file = open("train_data_file.txt", 'rb')
[x_tr, x_val, y_tr, y_val] = np.load(train_data_file, allow_pickle=True)
train_data_file.close()
# train_data_file = open("train_data_file.txt", 'rb')
# [x_tr, x_val, y_tr, y_val] = np.load(train_data_file, allow_pickle=True)
# train_data_file.close()
def predictSamples(audio):
prob=model.predict(audio.reshape(1,8000,1))
......
......@@ -128,12 +128,15 @@ def train():
pickle.dump(file=all_labels_file, obj=all_label)
all_labels_file.close()
return False
all_waves_file = open('all_waves_file.txt', 'wb+')
pickle.dump(file=all_waves_file, obj=all_wave)
all_waves_file.close()
print('Done: creating labels and waves files')
return False
le = LabelEncoder()
y = le.fit_transform(all_label)
classes = list(le.classes_)
......
......@@ -26,7 +26,6 @@ from .model.predict import predict
from pydub import AudioSegment
import numpy as np
class UserViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
......@@ -80,7 +79,8 @@ class MlModelViewSet(viewsets.ViewSet):
with open("output.m4a", "wb") as f:
f.write(bytesio_object.getbuffer())
path = os.path.abspath("output.m4a")
print(path)
# convert wav to mp3
audSeg = AudioSegment.from_file("output.m4a")
audSeg.export('output.wav', format="wav")
......@@ -97,7 +97,7 @@ class MlModelViewSet(viewsets.ViewSet):
print(samples.shape)
else:
len = 8000 - samples.shape[0]
new_arr = np.zeroes(len, )
new_arr = np.zeros(len, )
samples = np.concatenate((samples, new_arr))
print(samples.shape)
......
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment