def predict_url(urls, merge=True): """ Function to predict an url """ catch_url_error(urls) if not loaded: load_inference_model() urllib.request.urlretrieve(urls['urls'][0], '/tmp/file.wav') pred_lab, pred_prob =label_wav.predict('/tmp/file.wav', LABELS_FILE, MODEL_NAME, "wav_data:0","labels_softmax:0", 3) return format_prediction(pred_lab, pred_prob)
def predict_data(audios, merge=True): """ Function to predict an audio file """ if not loaded: load_inference_model() if not isinstance(audios, list): audios = [audios] filenames = [] for audio in audios: thename=audio['files'].filename thefile="/tmp/"+thename audio['files'].save(thefile) pred_lab, pred_prob =label_wav.predict(thefile, LABELS_FILE, MODEL_NAME, "wav_data:0","labels_softmax:0", 3) return format_prediction(pred_lab, pred_prob)
def predict_data(args): """ Function to predict an audio file """ # # Check user configuration # update_with_query_conf(args) # conf = config.conf_dict if not loaded: load_inference_model() # Create a list with the path to the audios filenames = [f.filename for f in args['files']] pred_lab, pred_prob = label_wav.predict(filenames[0], LABELS_FILE, MODEL_NAME, "wav_data:0", "labels_softmax:0", 3) return format_prediction(pred_lab, pred_prob)
def predict_url(args): """ Function to predict an url """ # # Check user configuration # update_with_query_conf(args) # conf = config.conf_dict catch_url_error(args['urls']) # Load model if needed if not loaded: load_inference_model() # Download the url urllib.request.urlretrieve(args['urls'][0], '/tmp/file.wav') pred_lab, pred_prob = label_wav.predict('/tmp/file.wav', LABELS_FILE, MODEL_NAME, "wav_data:0", "labels_softmax:0", 3) return format_prediction(pred_lab, pred_prob)