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
19
src/App.jsx
19
src/App.jsx
|
@ -254,18 +254,23 @@ Teacher: Good job! How about Magic – something special and powerful.
|
|||
});
|
||||
};
|
||||
|
||||
const toggleRecording = () => {
|
||||
if (!isRecording) {
|
||||
const startRecording = () => {
|
||||
if (!isRecording && mediaRecorderRef.current) {
|
||||
audioChunksRef.current = [];
|
||||
mediaRecorderRef.current.start();
|
||||
setIsRecording(true);
|
||||
monitorSilence();
|
||||
} else {
|
||||
}
|
||||
};
|
||||
|
||||
const stopRecording = () => {
|
||||
if (isRecording && mediaRecorderRef.current) {
|
||||
mediaRecorderRef.current.stop();
|
||||
setIsRecording(false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
|
||||
<div className="app-container">
|
||||
|
@ -299,10 +304,14 @@ Teacher: Good job! How about Magic – something special and powerful.
|
|||
|
||||
<div className="button-container">
|
||||
<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'}`}
|
||||
>
|
||||
{isRecording ? 'ฉันพูดเสร็จแล้ว' : 'พูด'}
|
||||
{isRecording ? 'กำลังพูด...' : 'กดค้างเพื่อพูด'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue