import json, re, os, subprocess, uuid, sys
from flask import Flask, redirect, url_for, request, render_template, jsonify, Response
import pandas as pd
import numpy as np
from speakerDiarization import getSpk  


app = Flask(__name__)


@app.route('/stt/spk', methods=['POST'])
def transcribe():
    filename = str(uuid.uuid1())+".txt"
    if request.method == 'POST':
        incomingMessage = request.form['text']
        getSpk(incomingMessage,  "segments/"+filename)
    return jsonify({
    'message': "http://0.0.0.0:9034/stt/spk/"+filename,
    'success': True
    }), 200
def getfile():
    file = request.files['file']
    return file.read()

@app.route("/stt/spk/<filename>", methods=['GET'])
def getfile(filename):
  try:
    if request.method == 'GET':
        with open('segments/'+filename) as f:
            file_content = f.read()
        return file_content  
  except FileNotFoundError:
        abort(404)

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=9034)    


import json, re, os, subprocess, uuid, sys
from flask import Flask, redirect, url_for, request, render_template, jsonify, Response
import pandas as pd
import numpy as np
from speakerDiarization import getSpk  


app = Flask(__name__)


@app.route('/stt/spk', methods=['POST'])
def transcribe():
    filename = str(uuid.uuid1())+".txt"
    if request.method == 'POST':
        incomingMessage = request.form['text']
        getSpk(incomingMessage,  "segments/"+filename)
    return jsonify({
    'message': "http://0.0.0.0:9034/stt/spk/"+filename,
    'success': True
    }), 200
def getfile():
    file = request.files['file']
    return file.read()

@app.route("/stt/spk/<filename>", methods=['GET'])
def getfile(filename):
  try:
    if request.method == 'GET':
        with open('segments/'+filename) as f:
            file_content = f.read()
        return file_content  
  except FileNotFoundError:
        abort(404)

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=9034)    

