react-edge-tts
Version:
Generate text-to-speech narration for React content using Microsoft Edge TTS
29 lines • 1.21 kB
JavaScript
import React from 'react';
import { VOICE_OPTIONS } from '../core/types';
const defaultIndicatorStyle = {
position: 'absolute',
top: -20,
right: 0,
fontSize: '0.8em',
color: '#666',
background: '#f0f0f0',
padding: '2px 4px',
borderRadius: '3px',
};
export const Narrate = ({ children, title, voice = VOICE_OPTIONS.US_FEMALE, rate = 1, volume = 1, pitch = 1, outputPath, showIndicator = process.env.NODE_ENV === 'development', indicatorStyle, }) => {
if (showIndicator) {
return (React.createElement("span", { "data-narration-title": title, style: { position: 'relative' } },
children,
React.createElement("span", { style: { ...defaultIndicatorStyle, ...indicatorStyle } },
"\uD83C\uDF99\uFE0F Narration: ",
title,
voice !== VOICE_OPTIONS.US_FEMALE && (React.createElement("small", { style: { marginLeft: 4, opacity: 0.8 } },
"(",
voice.split('-')[1],
")")))));
}
return React.createElement(React.Fragment, null, children);
};
// Export voice options for easy access
export { VOICE_OPTIONS };
//# sourceMappingURL=Narrate.js.map