Skip to content

Commit

Permalink
feat: Delete Useless Code
Browse files Browse the repository at this point in the history
  • Loading branch information
SangWoo9734 committed Jul 16, 2024
1 parent 03b88f1 commit ebe2994
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/components/voicechallenge/VoiceAnswerEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const VoiceAnswerEditor = ({
isText
/>
{status === 'view' && (
<span className={answerClass}>
<span className={answerClass} onClick={handleClick}>
{answer ? (
<>
<audio className="flex-1" controls src={answer} />
Expand Down
43 changes: 1 addition & 42 deletions src/components/voicechallenge/VoiceTranscriber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
GetTranscriptionJobCommandInput,
} from '@aws-sdk/client-transcribe';
import axios from 'axios';
import React, { useState, useRef, useEffect } from 'react';
import React, { useState, useRef } from 'react';
import { AudioVisualizer, LiveAudioVisualizer } from 'react-audio-visualize';
import { HiMiniStop } from 'react-icons/hi2';
import { MdFiberManualRecord } from 'react-icons/md';
Expand Down Expand Up @@ -40,29 +40,11 @@ const AudioTranscriber: React.FC<Props> = ({
const [jobStatus, setJobStatus] = useState<string>('');
const [isRecording, setIsRecording] = useState<boolean>(false);
const [recordFile, setRecordFile] = useState<File | null>(null);
const [isPlaying, setIsPlaying] = useState<boolean>(false);
const mediaRecorderRef = useRef<MediaRecorder | null>(null);
const audioChunksRef = useRef<Blob[]>([]);
const [blob, setBlob] = useState<Blob>();
const audioRef = useRef<HTMLAudioElement>(null);

useEffect(() => {
setIsPlaying(false);
}, [recordFile]);

useEffect(() => {
if (audioRef.current) {
audioRef.current.addEventListener('ended', () => setIsPlaying(false));
}
return () => {
if (audioRef.current) {
audioRef.current.removeEventListener('ended', () =>
setIsPlaying(false),
);
}
};
}, []);

const startRecording = async () => {
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
const mediaRecorder = new MediaRecorder(stream);
Expand Down Expand Up @@ -172,21 +154,6 @@ const AudioTranscriber: React.FC<Props> = ({
}
};

const handleAudioPlayback = async () => {
if (audioRef.current) {
try {
if (isPlaying) {
await audioRef.current.pause();
} else {
await audioRef.current.play();
}
setIsPlaying(!isPlaying);
} catch (err) {
console.error('Error handling audio playback:', err);
}
}
};

return (
<div className="flex flex-col gap-4">
<div className="flex flex-col items-center rounded-xl bg-background p-4 font-ryurue text-ryurue-base">
Expand Down Expand Up @@ -218,13 +185,6 @@ const AudioTranscriber: React.FC<Props> = ({
gap={2}
barColor={'#E16262'}
/>
{/* <button onClick={handleAudioPlayback}>
{isPlaying ? (
<HiMiniPause size={24} />
) : (
<HiMiniPlay size={24} />
)}
</button> */}
<audio
className="w-full"
ref={audioRef}
Expand Down Expand Up @@ -268,4 +228,3 @@ const AudioTranscriber: React.FC<Props> = ({
};

export default AudioTranscriber;
``;

0 comments on commit ebe2994

Please sign in to comment.