generated from amosproj/amos202Xss0Y-projname
-
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.
Merge pull request #274 from amosproj/268-integrate-LLM-dropdown
Multiple LLM Answer Queries + Voice Output Mutable and Doesn't Read Links
- Loading branch information
Showing
10 changed files
with
106 additions
and
25 deletions.
There are no files selected for viewing
Binary file added
BIN
+2.38 MB
Documentation/Demo_Videos/sprint12/MultipleLLMQueries_VoiceReadingMutable.m4v
Binary file not shown.
Binary file not shown.
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
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
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
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,49 @@ | ||
import * as Speech from 'expo-speech'; | ||
import React, { useEffect, useState } from 'react'; | ||
import { IconButton } from 'react-native-paper'; | ||
import { Style } from './style'; | ||
|
||
export function SpeakButton(props: { response: string }) { | ||
const [isSpeaking, setIsSpeaking] = useState(false); | ||
|
||
// Function to remove links from the text | ||
function extractReadableText(response: string): string { | ||
// Regular expression to match http and https links | ||
const linkRegex = /(https?:\/\/[^\s]+)|(www\.[^\s]+)/g; | ||
// Remove links from the text | ||
return response.replace(linkRegex, ''); | ||
} | ||
|
||
useEffect(() => { | ||
return () => { | ||
Speech.stop(); | ||
}; | ||
}, []); | ||
|
||
// if button is pressed | ||
const handleSpeech = () => { | ||
if (isSpeaking) { | ||
setIsSpeaking(false); | ||
Speech.stop(); | ||
} else { | ||
setIsSpeaking(true); | ||
const readableText = extractReadableText(props.response); | ||
Speech.speak(readableText, { | ||
language: 'en-US', | ||
pitch: 1, | ||
rate: 1, | ||
onDone: () => setIsSpeaking(false), | ||
onError: () => setIsSpeaking(false) | ||
}); | ||
} | ||
}; | ||
|
||
return ( | ||
<IconButton | ||
icon={!isSpeaking ? 'volume-up' : 'volume-mute'} | ||
size={16} | ||
onPress={handleSpeech} | ||
style={Style.speakButton} | ||
/> | ||
); | ||
} |
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,8 @@ | ||
import { StyleSheet } from 'react-native'; | ||
|
||
export const Style = StyleSheet.create({ | ||
speakButton: { | ||
alignSelf: 'center', | ||
margin: 0 | ||
} | ||
}); |
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
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,6 +1,5 @@ | ||
export const LLM_MODELS = [ | ||
{ key: 'gpt-4', name: 'OpenAi' }, | ||
{ key: 'google', name: 'Gemini' }, | ||
{ key: 'mistral', name: 'Mistral' }, | ||
{ key: 'claude', name: 'Claude' } | ||
]; |
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