-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2449f9e
commit 9a4bfae
Showing
7 changed files
with
137 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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* |
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from "react"; | ||
|
||
function AudioOutput() { | ||
return <></>; | ||
} | ||
|
||
export default AudioOutput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |