diff --git a/earth/0.1_treasure/index.html b/earth/0.1_treasure/index.html new file mode 100644 index 0000000..4a07d61 --- /dev/null +++ b/earth/0.1_treasure/index.html @@ -0,0 +1,85 @@ + + + + + + Treasure Hunt App + + +

Treasure Hunt

+

Waiting for coordinates...

+ + + + diff --git a/earth/rec2text/api.py b/earth/rec2text/api.py new file mode 100644 index 0000000..6327839 --- /dev/null +++ b/earth/rec2text/api.py @@ -0,0 +1,46 @@ +#!/bin/python3 +import os +import time +from fastapi import FastAPI, File, UploadFile +from fastapi.responses import JSONResponse +from fastapi.middleware.cors import CORSMiddleware +import whisper + +app = FastAPI() + +# Enable CORS for all origins +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], # Set this to ["*"] to allow all origins, or specify your trusted origins + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + +whisper = whisper.load_model("medium.en") + +@app.post("/speechToText") +async def speech_to_text(file: UploadFile = File(...)): + try: + # Save the uploaded audio file locally + audio_path = "temp_audio.wav" + with open(audio_path, "wb") as audio_file: + audio_file.write(file.file.read()) + + # Wait for the file to be fully written + while os.path.getsize(audio_path) == 0: + time.sleep(0.1) # Adjust the sleep duration as needed + + # Use whisper to convert speech to text + text = whisper.transcribe(audio_path, language="en")['text'] + + # Return the transcribed text + return text + + except Exception as e: + return JSONResponse(content={"error": str(e)}, status_code=500) + +if __name__ == "__main__": + import uvicorn + + uvicorn.run(app, host="0.0.0.0", port=9000) diff --git a/earth/rec2text/index.html b/earth/rec2text/index.html new file mode 100644 index 0000000..041308f --- /dev/null +++ b/earth/rec2text/index.html @@ -0,0 +1,110 @@ + + + + + + Audio Recorder + + +

Audio Recorder

+

Press the button to start recording. Click again to stop recording and send the audio.

+ + + +
+ + +