s2t-ts
v1.1.2
Published
speech to text
Readme
Speech to Text Service
A lightweight TypeScript wrapper for the Web Speech API that provides speech recognition functionality.
Features
- Browser speech recognition support detection
- Continuous speech recognition
- Language switching support
- TypeScript support
- Event-based architecture
Installation
npm install s2t-tsUsage
import STTService from "s2t-ts";
// Set up event handlers
STTService.onResult = (text) => {
console.log("Recognized text:", text);
};
STTService.onError = (error) => {
console.error("Error:", error);
};
STTService.onEnd = () => {
console.log("Recognition ended");
};
// Switch language (optional) // 'en-US' by default
STTService.setLanguage("ru-RU");
// Start recognition
STTService.start();
// Stop recognition
STTService.stop();API
Methods
start(): Starts speech recognitionstop(): Stops speech recognitionsetLanguage(lang): Sets recognition language
Properties
isListening: Boolean indicating if recognition is activeonResult(text: string): Callback for recognition resultsonError(error: string): Callback for error handlingonEnd(): Callback for recognition end event
Browser Support
This service requires a browser that supports the Web Speech API. Currently supported in:
- Chrome
- Edge
- Safari
- Firefox
License
MIT
