Skip to content

Commit

Permalink
Remove duplicate .gitignore file
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-karlsson committed Apr 20, 2024
1 parent 2449f9e commit 9a4bfae
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 26 deletions.
28 changes: 25 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
.env
.DS_Store
node_modules
client
server
build

# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
23 changes: 0 additions & 23 deletions client/.gitignore

This file was deleted.

Binary file added client/public/images/foods/lollypop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions client/src/components/AudioOutput.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from "react";

function AudioOutput() {
return <></>;
}

export default AudioOutput;
12 changes: 12 additions & 0 deletions client/src/components/ConversationControls.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react";

function ConversationControls({ isPaused, onPauseResume, onSkipForward }) {
return (
<div style={{ pointerEvents: "auto" }}>
<button onClick={onPauseResume}>{isPaused ? "Resume" : "Pause"}</button>
<button onClick={onSkipForward}>Skip forward</button>
</div>
);
}

export default ConversationControls;
82 changes: 82 additions & 0 deletions client/src/components/Output.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import React, { useState, useEffect } from "react";
import TextOutput from "./TextOutput";
import ConversationControls from "./ConversationControls";

function Output({ conversation }) {
const [currentMessageIndex, setCurrentMessageIndex] = useState(0);
const [currentSnippetIndex, setCurrentSnippetIndex] = useState(0);
const [currentMessageTextSnippet, setCurrentMessageTextSnippet] =
useState("");
const [initialize, setInitialize] = useState(true); // Flag to control initialization
const [isPaused, setIsPaused] = useState(false);

// Function to calculate the display time based on text length
const calculateDisplayTime = (text) => Math.max(3, text.length * 0.05);

function handlePauseResume() {
if (!isPaused) {
console.log("Pausing");
} else {
console.log("Resuming");
}

setIsPaused(!isPaused);
}

function handleSkipForward() {
// TODO: See if last message before skipping forward

console.log("Skipping forward");
}

useEffect(() => {
if (initialize && conversation.length > 0) {
setCurrentMessageIndex(0);
setCurrentSnippetIndex(0);
setInitialize(false); // Reset initialization flag after first setup
}
}, [conversation, initialize]);

useEffect(() => {
const processSnippets = () => {
if (conversation.length > currentMessageIndex) {
const snippets =
conversation[currentMessageIndex].text.split(/(?<=\.\s)/);
if (snippets.length > currentSnippetIndex) {
setCurrentMessageTextSnippet(snippets[currentSnippetIndex]);
const timeout = setTimeout(() => {
if (currentSnippetIndex < snippets.length - 1) {
setCurrentSnippetIndex(currentSnippetIndex + 1);
} else if (currentMessageIndex < conversation.length - 1) {
setCurrentMessageIndex(currentMessageIndex + 1);
setCurrentSnippetIndex(0);
}
}, calculateDisplayTime(snippets[currentSnippetIndex]) * 1000);
return () => clearTimeout(timeout);
}
}
};

processSnippets();
}, [currentMessageIndex, currentSnippetIndex, conversation]);

return (
<div>
<h2>
Speaker:{" "}
{conversation.length > 0
? conversation[currentMessageIndex].speaker
: ""}
</h2>
<TextOutput currentMessageTextSnippet={currentMessageTextSnippet} />
<AudioOutput />
<ConversationControls
isPaused={isPaused}
onPauseResume={handlePauseResume}
onSkipForward={handleSkipForward}
/>
</div>
);
}

export default Output;
11 changes: 11 additions & 0 deletions client/src/global-options.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"gptModel": "gpt-3.5-turbo-1106",
"temperature": 1,
"maxTokens": 200,
"frequency_penalty": 0,
"presence_penalty": 0,
"trimSentance": false,
"trimParagraph": true,
"show_trimmed": true,
"conversationMaxLength": 10
}

0 comments on commit 9a4bfae

Please sign in to comment.