-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
28 lines (20 loc) · 714 Bytes
/
app.py
File metadata and controls
28 lines (20 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import random
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import Pipeline
import pickle
from flask import Flask, request, render_template, jsonify
with open('cust_voice_model.pkl', 'rb') as f:
model = pickle.load(f)
app = Flask(__name__, static_url_path="")
@app.route('/')
def index():
"""Return the main page."""
return render_template('index.html')
@app.route('/predict', methods=['GET', 'POST'])
def predict():
"""Return a random prediction."""
data = request.json
prediction = model.predict([data['user_input']])
return jsonify({'Our prediction': prediction[0]})