Documentation
¶
Overview ¶
Package tts2media runs TTS engines, converts their output to mp3 and ogg (as audio files) and makes videos from images or other videos.
Files created by all functions and methods in this package are stored under the directory passed to SetDataDir(), and read from a subdirectory, named "tmp", that must be created under the same directory. If SetDataDir() isn't called, the media files will be saved in the current working directory.
saveDir, err := ioutil.TempDir(os.TempDir(), "") ... err = os.Mkdir(saveDir+"tmp", 0700) ... SetDataDir(saveDir) ... espeak := &EspeakSpeech{ Text: "Hello World!", // text to turn to speech Lang: "en", // language Speed: "135", // speed Gender: "m", // gender Altvoice: "0", // alternative voice Quality: "high", // quality of output mp3/ogg audio Pitch: "50", // pitch } media, err := espeak.NewEspeakSpeech() ... err = media.ToAudio() ... media.RemoveWAV()
Other than RemoveWAV(), functions don't remove any files.
For the functions of this package that create videos, and unless specified otherwise, the filenames passed should be the same as the input audio files, and should not contain extensions.
Index ¶
- Variables
- func Duration(path string) (string, error)
- func FromVideo(Audio string, lengthAsVideo bool) (string, error)
- func ImageToVideo(Audio, imageExtension string) (string, error)
- func SetDataDir(dataDir string)
- func Type(path string) (string, error)
- type EspeakSpeech
- type Media
- type PicoTTSSpeech
Constants ¶
This section is empty.
Variables ¶
var FilenameLen int = 10
FilenameLen: length of the string returned as filename for media files (mp3, ogg, mp4, webm)
Functions ¶
func FromVideo ¶
FromVideo creates videos from inputs video and Ogg audio files (previously generated by ToAudio). The last argument indicates the length, in seconds, of the output file: if lengthAsVideo is true, the length of the output file, in seconds, is the same as the input video. Otherwise, it is the same as the input audio. The output videos are stored with the same format (plus corresponding extensions) as input files. FromVideo checks if the (OGG) audio file exists, and detects the mime type of the input video.
func ImageToVideo ¶
ImageToVideo creates two videos, encoded as MP4 and Webm, from the input files. Inputs are: an image file and an OGG audio file (previously generated by ToAudio). The filename of the input images should include the file extension. The output video is stored in dataPath, with formats (= extensions) webm and mp4. ImageToVideo checks if the (OGG) audio file exists.
func SetDataDir ¶
func SetDataDir(dataDir string)
SetDataDir sets the directories where the media files are saved
Types ¶
type EspeakSpeech ¶
type EspeakSpeech struct { Text string Lang string Speed string Gender string Altvoice string Quality string Pitch string }
EspeakSpeech: values needed to create wav files by calling the Espeak speech engine
Language: language of the speaker, aka "voice name" in espeak; values: "af", "bs", "ca", "cs", "cy", "de", "en", "en-sc", "en-uk", "en-uk-north", "en-uk-rp", "en-uk-wmids", "en-us", "en-wi", "eo", "es", "es-la", "fi", "fr", "fr-be", "grc", "hr", "hu", "id", "is", "it", "jbo", "ku", "la", "lv", "mk", "nl", "no", "pl", "pt-pt", "pt", "ro", "ru", "sk", "sq", "sr", "sv", "sw", "tr", "vi", "zh", "zh-yue", "hi", "el", "ta"
Speed: speed in words per minute; values: from "80" to "390"
Gender: gender of the speaker; values: "m" for male, and "f" for female. note: not all voices support different genders
Altvoice: alternative voice; values: from "0" to "5"
Quality: quality of the output MP3/OGG audio; values: "high", "medium" or "low"
Pitch: pitch adjustment; values: from "0" to "99"
func (*EspeakSpeech) NewEspeakSpeech ¶
func (s *EspeakSpeech) NewEspeakSpeech() (*Media, error)
NewEspeakSpeech creates (after validating inputs) a WAV file with a random filename If the operation succeeds, it returns the filename (without path or extension) and a nil error. Otherwise, returns an empty string and an error
type Media ¶
Media: values needed to create media (mp3, ogg, mp4, webm) files generated by the speech engines
func (*Media) ImageToVideo ¶
ImageToVideo creates Webm and MP4 files from the file specified as the first argument and the ogg file generated by ToAudio()
type PicoTTSSpeech ¶
PicoTTSSpeech: values needed to create wav files by calling the PicoTTS speech engine
func (*PicoTTSSpeech) NewPicoTTSSpeech ¶
func (s *PicoTTSSpeech) NewPicoTTSSpeech() (*Media, error)
NewPicoTTSSpeech creates (after validating inputs) a WAV file with a random filename. If the operation succeeds, it returns the filename (without path or extension) and a nil error. Otherwise, returns an empty string and an error