Skip to content

Commit

Permalink
removed audio
Browse files Browse the repository at this point in the history
  • Loading branch information
aadillpickle committed May 11, 2023
1 parent 09bb868 commit 0370619
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 197 deletions.
23 changes: 0 additions & 23 deletions backend/audio.py

This file was deleted.

16 changes: 0 additions & 16 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from dotenv import load_dotenv
from posthog import Posthog
from therapist import create_new_user, therapize, add_email_and_credits
from audio import get_audio_from_text
from db import USERS, PROMPTS, delete_user_message_history, store_usage, add_credits

import os
Expand Down Expand Up @@ -147,21 +146,6 @@ def message_history_route():
mimetype=mimetype
)

@app.route('/get-audio', methods=['POST'])
def get_audio():
status = 0
try:
req_json = request.get_json()
text = req_json['text']
audio_data = get_audio_from_text(text)

status = 200
return Response(audio_data, status=status, content_type='audio/mpeg')
except Exception as e:
status = 400
print(e)
return Response(f"Server error: {e}", status=status)

@app.route('/credits', methods=['POST'])
def credits_route():
#Sample response attributes
Expand Down
14 changes: 0 additions & 14 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"jwt-decode": "^3.1.2",
"posthog-js": "^1.53.2",
"react": "^18.2.0",
"react-audio-voice-recorder": "^1.0.10",
"react-dom": "^18.2.0",
"react-modal": "^3.16.1",
"react-router-dom": "^6.10.0",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Credits.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Credits = () => {
}
return (
<button
className="text-black font-gilroy absolute top-0 right-0 text-lg m-4 border-2 border-slate-600 rounded-lg p-4"
className="text-black font-gilroy absolute top-0 right-0 text-xs md:text-lg m-4 border-2 border-slate-600 rounded-lg p-4"
onClick={handleCheckout}
>
Buy credits
Expand Down
31 changes: 1 addition & 30 deletions frontend/src/pages/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import LoadingSpinner from "../LoadingSpinner";
import Credits from "./Credits";
import MessageHistory from "./MessageHistory";
import Modal from "react-modal";
import VoiceRecorderButton from "./VoiceRecorderButton";
import PlayAudioButton from "./PlayAudioButton";

Modal.setAppElement("#root");

Expand All @@ -16,8 +14,6 @@ function Main() {
const [isHistoryModalOpen, setIsHistoryModalOpen] = useState(false);
const [loading, setLoading] = useState(false);
const [messageHistory, setMessageHistory] = useState([]);
const [receivedAudio, setReceivedAudio] = useState(null);
const [audioButtonHidden, setAudioButtonHidden] = useState(true);
const [buttonText, setButtonText] = useState('Delete all my chat data');
const [userInfo, setUserInfo] = useUserInfo('userInfo');
const [credits, setCredits] = useState(0);
Expand All @@ -26,14 +22,6 @@ function Main() {
setIsHistoryModalOpen(!isHistoryModalOpen);
};

const handleTranscription = (transcript) => {
inputRef.current.value += transcript;
inputRef.current.selectionStart = inputRef.current.selectionEnd =
inputRef.current.value.length;
inputRef.current.scrollLeft = inputRef.current.scrollWidth;
inputRef.current.scrollTop = inputRef.current.scrollHeight;
};

const getCredits = async () => {
const resp = await fetch(process.env.REACT_APP_API_ROOT + "/credits", {
method: "POST",
Expand All @@ -48,7 +36,6 @@ function Main() {

const handleSubmit = async (event) => {
setLoading(true);
setAudioButtonHidden(true);
const input = inputRef.current.value;
inputRef.current.value = "";
event.preventDefault();
Expand All @@ -70,20 +57,8 @@ function Main() {
let responseData = response["message"];

if (responseData["therapist_response"]) {
const resp2 = await fetch(process.env.REACT_APP_API_ROOT + "/get-audio", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({text: responseData["therapist_response"]}),
});
const blob = await resp2.blob();
const audioURL = URL.createObjectURL(blob);
setReceivedAudio(audioURL);

setMessageHistory(responseData["message_history"]);
setData(responseData["therapist_response"]);
setAudioButtonHidden(false);
} else {
setData(responseData)
}
Expand Down Expand Up @@ -115,7 +90,7 @@ function Main() {
};
return (
<div className="bg-transparent w-full h-screen flex flex-col items-center mb-4 justify-center gap-4">
<div className="text-lg w-5/6 md:text-4xl md:w-1/3 text-center font-sans text-slate-700 mb-4 font-bold">
<div className="text-lg w-5/6 md:text-4xl md:w-1/3 text-center font-sans text-slate-700 md:mb-2 font-bold">
How are you, really?
</div>
<textarea
Expand All @@ -131,9 +106,6 @@ function Main() {
}
}}
></textarea>
<VoiceRecorderButton
onTranscribe={handleTranscription}
/>
<button
className={
"rounded-md text-lg w-3/4 md:w-1/3 h-16 text-white bg-slate-800 disabled:opacity-50"
Expand All @@ -152,7 +124,6 @@ function Main() {
{/* <div className="text-center text-xs">Scroll for more ↓</div> */}
</>
)}
{receivedAudio && <PlayAudioButton hidden={audioButtonHidden} audio={receivedAudio} />}
{userInfo.email && <><button
className="text-black font-gilroy absolute bottom-0 right-0 text-xs md:text-lg m-4 border-2 border-slate-600 rounded-lg p-4"
onClick={deleteAllData}
Expand Down
49 changes: 0 additions & 49 deletions frontend/src/pages/PlayAudioButton.js

This file was deleted.

63 changes: 0 additions & 63 deletions frontend/src/pages/VoiceRecorderButton.js

This file was deleted.

0 comments on commit 0370619

Please sign in to comment.