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

Update to use Flask-SocketIO and get audio from browser mic #4

Merged
merged 10 commits into from
Jun 4, 2024

Conversation

SandraRodgers
Copy link
Contributor

No description provided.

@SandraRodgers SandraRodgers merged commit adec194 into main Jun 4, 2024
@SandraRodgers
Copy link
Contributor Author

SandraRodgers commented Jun 4, 2024

Thank you @etiennecallies for this PR. I apologize it took so long to review it!

I have made changes to your PR based on the Python SDK's recommended implementation. So it now gives a good example for how to use the Python SDK for this use case. I also use the most updated version of the SDK.

If you have a chance to run the code again and give feedback, I would appreciate it!

@etiennecallies
Copy link
Contributor

Hi @SandraRodgers ! No worries, it's an honor to become a contributor ;) I just tried it and it works fine 👌🏻 Congrats!

Good job on the code refactoring. My only remark is that we could use only one port (and it's my fault). Here is how:

from flask import Flask, render_template, session
from flask_socketio import SocketIO

FLASK_HOST = "127.0.0.1"
FLASK_PORT = "5001"
FLASK_DEBUG = "True"

app = Flask("deep_audio_ai")
socketio = SocketIO(app, cors_allowed_origins=[f"http://{FLASK_HOST}:{FLASK_PORT}"])

@app.route("/")
def index():
    return render_template("index.html")

@socketio.on("connect")
def handle_connect(auth):
    logging.info("Client connecting")
    socketio.start_background_task(target=on_connect)

...

if __name__ == "__main__":
    logging.info("Starting Flask")
    socketio.run(
        app,
        allow_unsafe_werkzeug=True,
        debug=FLASK_DEBUG == "True",
        host=FLASK_HOST,
        port=int(FLASK_PORT),
    )

All the best

@SandraRodgers
Copy link
Contributor Author

@etiennecallies I created an issue so that I don't forget to make this update (I'm working on other things at the moment). If you feel like submitting another PR, that would be welcome!

#5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants