el-tocino / localcroft

Bits for locally-served Mycroft instances
https://mycroft.ai
35 stars 10 forks source link

Find a way to avoid writing output temp file #1

Closed el-tocino closed 4 years ago

el-tocino commented 4 years ago

https://github.com/el-tocino/localcroft/blob/02c8d8aae0a4d79e810328e684811b8473f38e6d/mycroft-core/mycroft/stt/__init__.py#L307 https://github.com/el-tocino/localcroft/blob/02c8d8aae0a4d79e810328e684811b8473f38e6d/mycroft-core/mycroft/stt/__init__.py#L308 There's got to be a way to skip writing a temp file just to read it back in.

JarbasAl commented 4 years ago

what about

output = StringIO.StringIO()
sound.export(output, format="mp3")
JarbasAl commented 4 years ago

note: You can pass in a file-like object to .export() such as StringIO if you prefer, but you should know that internally pydub will still create a temporary file on disk (which is given to ffmpeg as path to store output when transcoding).