switch to push-to-talk
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
95318b86d4
commit
378b62a42c
1 changed files with 18 additions and 9 deletions
27
src/App.jsx
27
src/App.jsx
|
@ -254,18 +254,23 @@ Teacher: Good job! How about Magic – something special and powerful.
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleRecording = () => {
|
const startRecording = () => {
|
||||||
if (!isRecording) {
|
if (!isRecording && mediaRecorderRef.current) {
|
||||||
audioChunksRef.current = [];
|
audioChunksRef.current = [];
|
||||||
mediaRecorderRef.current.start();
|
mediaRecorderRef.current.start();
|
||||||
setIsRecording(true);
|
setIsRecording(true);
|
||||||
monitorSilence();
|
monitorSilence();
|
||||||
} else {
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const stopRecording = () => {
|
||||||
|
if (isRecording && mediaRecorderRef.current) {
|
||||||
mediaRecorderRef.current.stop();
|
mediaRecorderRef.current.stop();
|
||||||
setIsRecording(false);
|
setIsRecording(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
<div className="app-container">
|
<div className="app-container">
|
||||||
|
@ -299,10 +304,14 @@ Teacher: Good job! How about Magic – something special and powerful.
|
||||||
|
|
||||||
<div className="button-container">
|
<div className="button-container">
|
||||||
<button
|
<button
|
||||||
onClick={toggleRecording}
|
onMouseDown={startRecording}
|
||||||
|
onMouseUp={stopRecording}
|
||||||
|
onMouseLeave={stopRecording} // Ensures it stops if mouse leaves the button
|
||||||
|
onTouchStart={startRecording}
|
||||||
|
onTouchEnd={stopRecording}
|
||||||
className={`control-button ${isRecording ? 'recording' : 'idle'}`}
|
className={`control-button ${isRecording ? 'recording' : 'idle'}`}
|
||||||
>
|
>
|
||||||
{isRecording ? 'ฉันพูดเสร็จแล้ว' : 'พูด'}
|
{isRecording ? 'กำลังพูด...' : 'กดค้างเพื่อพูด'}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue