Spaces:
Sleeping
Sleeping
matt HOFFNER
commited on
Commit
·
f19a9bc
1
Parent(s):
a98ce53
revert
Browse files- app/input.tsx +6 -21
app/input.tsx
CHANGED
@@ -58,16 +58,13 @@ const VoiceInputForm: React.FC<VoiceInputFormProps> = ({ handleSubmit, input, se
|
|
58 |
if (transcriber.output) {
|
59 |
setRecognizedText(transcriber.output.text);
|
60 |
}
|
61 |
-
}, [transcriber
|
62 |
|
63 |
const handleTranscriptionComplete = () => {
|
64 |
-
// Create a synthetic event object
|
65 |
const syntheticEvent = {
|
66 |
preventDefault: () => {},
|
67 |
target: {
|
68 |
-
// Mimic the structure of your form's event.target here
|
69 |
elements: {
|
70 |
-
// Assuming the form has an input field named 'input'
|
71 |
input: {
|
72 |
value: recognizedText
|
73 |
}
|
@@ -93,21 +90,15 @@ const VoiceInputForm: React.FC<VoiceInputFormProps> = ({ handleSubmit, input, se
|
|
93 |
useEffect(() => {
|
94 |
const processRecording = async () => {
|
95 |
if (recordedBlob) {
|
96 |
-
const
|
97 |
-
|
98 |
-
|
99 |
-
const audioCTX = new AudioContext();
|
100 |
-
const arrayBuffer = fileReader.result as ArrayBuffer;
|
101 |
-
const decoded = await audioCTX.decodeAudioData(arrayBuffer);
|
102 |
-
startListening(decoded);
|
103 |
-
};
|
104 |
-
|
105 |
-
fileReader.readAsArrayBuffer(recordedBlob);
|
106 |
}
|
107 |
};
|
108 |
|
109 |
processRecording();
|
110 |
-
}, [recordedBlob, startListening]);
|
|
|
111 |
|
112 |
const vad = useMicVAD({
|
113 |
modelURL: "/_next/static/chunks/silero_vad.onnx",
|
@@ -226,12 +217,6 @@ const VoiceInputForm: React.FC<VoiceInputFormProps> = ({ handleSubmit, input, se
|
|
226 |
))}
|
227 |
</div>
|
228 |
)}
|
229 |
-
{recordedBlob && (
|
230 |
-
<audio controls>
|
231 |
-
<source src={URL.createObjectURL(recordedBlob)} type={recordedBlob.type} />
|
232 |
-
Your browser does not support the audio element.
|
233 |
-
</audio>
|
234 |
-
)}
|
235 |
<form onSubmit={handleSubmit} className={styles.form}>
|
236 |
<input
|
237 |
type="text"
|
|
|
58 |
if (transcriber.output) {
|
59 |
setRecognizedText(transcriber.output.text);
|
60 |
}
|
61 |
+
}, [transcriber]);
|
62 |
|
63 |
const handleTranscriptionComplete = () => {
|
|
|
64 |
const syntheticEvent = {
|
65 |
preventDefault: () => {},
|
66 |
target: {
|
|
|
67 |
elements: {
|
|
|
68 |
input: {
|
69 |
value: recognizedText
|
70 |
}
|
|
|
90 |
useEffect(() => {
|
91 |
const processRecording = async () => {
|
92 |
if (recordedBlob) {
|
93 |
+
const audioBuffer = await convertBlobToAudioBuffer(recordedBlob);
|
94 |
+
startListening(audioBuffer); // Start the transcription process
|
95 |
+
setRecordedBlob(null); // Reset the blob state if you want to prepare for a new recording
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
}
|
97 |
};
|
98 |
|
99 |
processRecording();
|
100 |
+
}, [recordedBlob, startListening]);
|
101 |
+
|
102 |
|
103 |
const vad = useMicVAD({
|
104 |
modelURL: "/_next/static/chunks/silero_vad.onnx",
|
|
|
217 |
))}
|
218 |
</div>
|
219 |
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
<form onSubmit={handleSubmit} className={styles.form}>
|
221 |
<input
|
222 |
type="text"
|