
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
@lakshmiprasanth/react-voice-to-text
Advanced tools
A modern React package for voice-to-text conversion with real-time speech recognition and file upload support
A modern React package for voice-to-text conversion with real-time speech recognition and file upload support. Built with TypeScript and optimized for browser environments.
npm install @lakshmiprasanth/react-voice-to-text
# or
yarn add @lakshmiprasanth/react-voice-to-text
import React from 'react';
import { VoiceToTextConverter } from '@lakshmiprasanth/react-voice-to-text';
function App() {
return (
<div className="App">
<VoiceToTextConverter />
</div>
);
}
import React from 'react';
import { useVoiceToText } from '@lakshmiprasanth/react-voice-to-text';
function VoiceRecorder() {
const {
isInitialized,
isRecording,
results,
error,
startRecording,
stopRecording,
clearResults
} = useVoiceToText();
return (
<div>
<button
onClick={isRecording ? stopRecording : startRecording}
disabled={!isInitialized}
>
{isRecording ? 'Stop Recording' : 'Start Recording'}
</button>
{error && <p>Error: {error}</p>}
<div>
{results.map((result, index) => (
<p key={index}>
{result.transcript} (Confidence: {(result.confidence * 100).toFixed(1)}%)
</p>
))}
</div>
</div>
);
}
The main component that provides a complete voice-to-text interface.
import { VoiceToTextConverter } from '@lakshmiprasanth/react-voice-to-text';
<VoiceToTextConverter
showFileUpload={true}
showVoiceRecorder={true}
showResults={true}
defaultLanguage="en-US"
onResult={(result) => console.log('New result:', result)}
onError={(error) => console.error('Error:', error)}
/>
A component for real-time voice recording.
import { VoiceRecorder } from '@lakshmiprasanth/react-voice-to-text';
<VoiceRecorder
language="en-US"
continuous={true}
interimResults={true}
onResult={(result) => console.log('Result:', result)}
onError={(error) => console.error('Error:', error)}
/>
A component for uploading and converting audio files.
import { FileUpload } from '@lakshmiprasanth/react-voice-to-text';
<FileUpload
acceptedFormats={['audio/*']}
maxFileSize={50 * 1024 * 1024} // 50MB
onConvert={(file, language) => {
console.log('Converting file:', file.name);
}}
onError={(error) => console.error('Error:', error)}
/>
A component for displaying transcription results.
import { ResultsDisplay } from '@lakshmiprasanth/react-voice-to-text';
<ResultsDisplay
results={results}
error={error}
showConfidence={true}
showStatus={true}
maxResults={50}
onClear={() => setResults([])}
/>
The main hook for voice-to-text functionality.
import { useVoiceToText } from '@lakshmiprasanth/react-voice-to-text';
const {
isInitialized,
isRecording,
isProcessing,
results,
error,
browserSupport,
startRecording,
stopRecording,
clearResults,
clearError,
updateConfig,
getConfig
} = useVoiceToText({
defaultRecognitionConfig: {
language: 'en-US',
continuous: true,
interimResults: true
},
onResult: (result) => console.log('Result:', result),
onError: (error) => console.error('Error:', error)
});
A simplified hook for voice recording.
import { useVoiceRecorder } from '@lakshmiprasanth/react-voice-to-text';
const {
isInitialized,
isRecording,
results,
error,
startRecording,
stopRecording,
clearResults
} = useVoiceRecorder({
language: 'en-US',
continuous: true,
interimResults: true
});
A hook for file upload functionality.
import { useFileUpload } from '@lakshmiprasanth/react-voice-to-text';
const {
selectedFile,
isConverting,
results,
error,
selectFile,
convertFile,
clearFile,
clearResults,
validateFile
} = useFileUpload({
acceptedFormats: ['audio/*'],
maxFileSize: 50 * 1024 * 1024,
onConvert: async (file, language) => {
// Handle file conversion
}
});
A low-level hook for direct speech recognition.
import { useSpeechRecognition } from '@lakshmiprasanth/react-voice-to-text';
const {
isSupported,
isListening,
transcript,
finalTranscript,
interimTranscript,
error,
start,
stop,
abort,
reset
} = useSpeechRecognition({
language: 'en-US',
continuous: true,
interimResults: true
});
All components come with built-in styles, but you can customize them using CSS classes or styled-components.
<VoiceRecorder
className="my-custom-recorder"
style={{
backgroundColor: '#f0f0f0',
borderRadius: '12px',
padding: '20px'
}}
/>
.my-custom-recorder {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border-radius: 16px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}
.my-custom-recorder button {
background: rgba(255, 255, 255, 0.2);
border: 1px solid rgba(255, 255, 255, 0.3);
color: white;
}
The package supports 60+ languages. Here are some popular ones:
en-US
en-GB
es-ES
fr-FR
de-DE
it-IT
pt-BR
ja-JP
ko-KR
zh-CN
ru-RU
ar-SA
import { VoiceToTextProvider } from '@lakshmiprasanth/react-voice-to-text';
<VoiceToTextProvider
options={{
defaultRecognitionConfig: {
language: 'en-US',
continuous: true,
interimResults: true,
maxAlternatives: 3
},
debug: false
}}
onResult={(result) => console.log('Result:', result)}
onError={(error) => console.error('Error:', error)}
onStart={() => console.log('Recording started')}
onStop={() => console.log('Recording stopped')}
>
<YourApp />
</VoiceToTextProvider>
import React from 'react';
import { useVoiceToText, RecordingControls, ResultsDisplay } from '@lakshmiprasanth/react-voice-to-text';
function CustomVoiceRecorder() {
const {
isInitialized,
isRecording,
results,
error,
startRecording,
stopRecording,
clearResults
} = useVoiceToText();
return (
<div className="custom-recorder">
<h2>Custom Voice Recorder</h2>
<RecordingControls
isRecording={isRecording}
onStart={startRecording}
onStop={stopRecording}
disabled={!isInitialized}
startText="π€ Start"
stopText="βΉοΈ Stop"
/>
<ResultsDisplay
results={results}
error={error}
onClear={clearResults}
showConfidence={true}
showStatus={true}
/>
</div>
);
}
import React from 'react';
import { useFileUpload, LanguageSelector } from '@lakshmiprasanth/react-voice-to-text';
function CustomFileUpload() {
const {
selectedFile,
isConverting,
results,
error,
selectFile,
convertFile,
clearResults
} = useFileUpload();
const [language, setLanguage] = useState('en-US');
const handleFileChange = (event) => {
const file = event.target.files[0];
if (file) {
selectFile(file);
}
};
return (
<div className="custom-file-upload">
<h2>Custom File Upload</h2>
<LanguageSelector
value={language}
onChange={setLanguage}
showLabel={true}
label="Select Language"
/>
<input
type="file"
accept="audio/*"
onChange={handleFileChange}
disabled={isConverting}
/>
{selectedFile && (
<div>
<p>Selected: {selectedFile.name}</p>
<button
onClick={() => convertFile(language)}
disabled={isConverting}
>
{isConverting ? 'Converting...' : 'Convert'}
</button>
</div>
)}
{error && <p className="error">Error: {error}</p>}
{results.length > 0 && (
<div>
<h3>Results:</h3>
{results.map((result, index) => (
<p key={index}>{result.transcript}</p>
))}
</div>
)}
</div>
);
}
The package uses the Web Speech API, which is supported in:
The package works on mobile devices, but requires HTTPS in production for microphone access.
git clone https://github.com/prasanth-sasuke/react-voice-to-text.git
cd react-voice-to-text
npm install
npm run build
npm test
npm run storybook
MIT License - see LICENSE file for details.
Contributions are welcome! Please see CONTRIBUTING.md for details.
Made with β€οΈ for the React community
FAQs
A modern React package for voice-to-text conversion with real-time speech recognition and file upload support
We found that @lakshmiprasanth/react-voice-to-text demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socketβs AI scanner detected the supply chain attack and flagged the malware.
Security News
CISAβs 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.