Message rendering (#6868)

Co-authored-by: luowei <glpat-EjySCyNjWiLqAED-YmwM>
Co-authored-by: crazywoola <427733928@qq.com>
Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com>
This commit is contained in:
Charlie.Wei
2024-09-05 21:00:09 +08:00
committed by GitHub
parent dadca0f91a
commit 3230f4a0ec
15 changed files with 1403 additions and 93 deletions

View File

@@ -16,11 +16,13 @@ import { audioToText } from '@/service/share'
type VoiceInputTypes = {
onConverted: (text: string) => void
onCancel: () => void
wordTimestamps?: string
}
const VoiceInput = ({
onCancel,
onConverted,
wordTimestamps,
}: VoiceInputTypes) => {
const { t } = useTranslation()
const recorder = useRef(new Recorder({
@@ -88,6 +90,7 @@ const VoiceInput = ({
const mp3File = new File([mp3Blob], 'temp.mp3', { type: 'audio/mp3' })
const formData = new FormData()
formData.append('file', mp3File)
formData.append('word_timestamps', wordTimestamps || 'disabled')
let url = ''
let isPublic = false
@@ -112,7 +115,7 @@ const VoiceInput = ({
onConverted('')
onCancel()
}
}, [])
}, [clearInterval, onCancel, onConverted, params.appId, params.token, pathname, wordTimestamps])
const handleStartRecord = async () => {
try {
await recorder.current.start()
@@ -146,7 +149,7 @@ const VoiceInput = ({
}
}
}
if (originDuration >= 120 && startRecord)
if (originDuration >= 600 && startRecord)
handleStopRecorder()
useEffect(() => {
@@ -204,7 +207,7 @@ const VoiceInput = ({
</div>
)
}
<div className={`w-[45px] pl-1 text-xs font-medium ${originDuration > 110 ? 'text-[#F04438]' : 'text-gray-700'}`}>{`0${minutes.toFixed(0)}:${seconds >= 10 ? seconds : `0${seconds}`}`}</div>
<div className={`w-[45px] pl-1 text-xs font-medium ${originDuration > 500 ? 'text-[#F04438]' : 'text-gray-700'}`}>{`0${minutes.toFixed(0)}:${seconds >= 10 ? seconds : `0${seconds}`}`}</div>
</div>
</div>
)