diff options
author | alyssaf16 <alyssa_feinberg@brown.edu> | 2024-09-29 16:21:57 -0400 |
---|---|---|
committer | alyssaf16 <alyssa_feinberg@brown.edu> | 2024-09-29 16:21:57 -0400 |
commit | 658fe77c26712a691ad346e187edeb587ec5c139 (patch) | |
tree | a33530b3fa4c9953fd64dcabb7921cbadab11d71 | |
parent | 6428e1a6235d609ab28f8f3b6d1029b852d01c99 (diff) |
more comments
-rw-r--r-- | src/client/views/nodes/ComparisonBox.tsx | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/client/views/nodes/ComparisonBox.tsx b/src/client/views/nodes/ComparisonBox.tsx index f05b672e9..30237ac64 100644 --- a/src/client/views/nodes/ComparisonBox.tsx +++ b/src/client/views/nodes/ComparisonBox.tsx @@ -367,6 +367,10 @@ export class ComparisonBox extends ViewBoxAnnotatableComponent<FieldViewProps>() this._props.DocumentView?.()._props.addDocument?.(newAudio); }; + /** + * Gets the transcription of an audio recording by sending the + * recording to backend. + */ pushInfo = async () => { const audio = { file: this._audio.url, @@ -377,7 +381,6 @@ export class ComparisonBox extends ViewBoxAnnotatableComponent<FieldViewProps>() }, }); this.Document.phoneticTranscription = response.data['transcription']; - console.log('RESPONSE: ' + response.data['transcription']); }; getYouTubeVideoId = (url: string) => { @@ -386,6 +389,10 @@ export class ComparisonBox extends ViewBoxAnnotatableComponent<FieldViewProps>() return match && match[2].length === 11 ? match[2] : null; }; + /** + * Gets the transcript of a youtube video by sending the video url to the backend. + * @returns transcription of youtube recording + */ youtubeUpload = async () => { const audio = { file: this.getYouTubeVideoId(StrCast(RTFCast(DocCast(this.dataDoc[this.fieldKey + '_1']).text)?.Text)), @@ -477,12 +484,6 @@ export class ComparisonBox extends ViewBoxAnnotatableComponent<FieldViewProps>() this._loading = true; const doc = DocCast(this.dataDoc[this.props.fieldKey + '_0']); - // if (true) { - // const s = await this.youtubeUpload(); - - // questionText = 'Question: ' + s; - // } - if (callType == GPTCallType.CHATCARD) { if (StrCast(RTFCast(DocCast(this.dataDoc[this.fieldKey + '_1']).text)?.Text) === '') { this._loading = false; @@ -531,6 +532,11 @@ export class ComparisonBox extends ViewBoxAnnotatableComponent<FieldViewProps>() } }; + /** + * Ask GPT for advice on how to improve speech by comparing the phonetic transcription of + * a users audio recording with the phonetic transcription of their intended sentence. + * @param phonemes + */ askGPTPhonemes = async (phonemes: string) => { const sentence = StrCast(RTFCast(DocCast(this.dataDoc[this.fieldKey + '_1']).text)?.Text); const phon = 'w ʌ ɪ z j ɔː ɹ n e ɪ m '; @@ -575,6 +581,10 @@ export class ComparisonBox extends ViewBoxAnnotatableComponent<FieldViewProps>() } }; + /** + * Display a user's speech to text result. + * @param e + */ handleResult = (e: SpeechRecognitionEvent) => { let interimTranscript = ''; let finalTranscript = ''; @@ -589,6 +599,11 @@ export class ComparisonBox extends ViewBoxAnnotatableComponent<FieldViewProps>() this._inputValue += finalTranscript; }; + /** + * Get images from unsplash api and place that will be placed inside generated flashcard. + * @param selection + * @returns Image Document + */ fetchImages = async (selection: string) => { try { const { data } = await axios.get(`${API_URL}?query=${selection}&page=1&per_page=${1}&client_id=Q4zruu6k6lum2kExiGhLNBJIgXDxD6NNj0SRHH_XXU0`); |