Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up the basic machine learning py #6

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions machine-learning-client/machine_learning_client.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
from flask import Flask, render_template, request, redirect, url_for, make_response, session
import os
from pymongo import MongoClient
import pymongo
import datetime
from bson.objectid import ObjectId
import speech_recognition as sr
import sys

app = Flask('project4')
r = sr.recognizer()

@app.route("/process_wav", methods=['GET', 'POST'])
def process_wav():
if request.method == 'POST':
audio_file = request.form.get("audio-recording")
dir = 'audio/'+str(audio_file)
def record_microphone():
with sr.Microphone() as source:
print("Please give your answer:")
audio = r.listen(source)
return audio

def audio_to_text(audio):
try:
transcription = r.recognize_google(audio)
print(transcription)
except sr.UnknownValueError:
print("Sorry, we could not recognize your response.")
except sr.RequestError as e:
print("Sorry, there appears to be an error with Google Speech to Text")

def grade_response(transcription):
print("working on it...")

def main():
print("Tell me a little bit about yourself")
audio = record_microphone()
transcription = audio_to_text(audio)
result = grade_response(transcription)

if __name__ == "__main__":
PORT = os.getenv('PORT', 5000)
app.run(debug=True,port=PORT)
main()
Loading