Open CalculusAce opened 3 years ago
Have you tried using the file:///
schema as a source? Ultimately, since you need to have a small web server running locally to respond to Yomichan's requests, you can just pass the file contents directly anyway.
Not sure how helpful this is to you given how much time has passed but I'll answer anyway incase someone stumbles upon this.
First, I tried using file:///
with no luck. But cyphar is right that you still need a web server for Yomichan to communicate with. I just tested serving local audio with my web server with a separate route that just hardcoded the filename. So inside the do_GET
function of a http.server.SimpleHTTPRequestHandler
with open('my_audio.mp3', 'rb') as f:
self.wfile.write(f.read())
return
You mentioned that your files are saved in a json file encoded in base64 strings. So maybe for you the code would look more like
# get term from query parameter
with open('my_files.json', 'r') as f:
files = json.load(f)
self.wfile.write(base64decode(files[term])))
return
In case anyone was looking for a local audio add-on, there's one here: https://github.com/themoeway/local-audio-yomichan (disclaimer: I'm the main contributor)
I wanted to see if you may be able to provide some advice for implementing a server for Yomichan audio that will work with content stored locally? I have a large number of local audio files that are already in base64 (it's stored in json as word : base64 audio), but I am not sure how to source them for Yomichan and facilitate playback. Is it possible to work with local content, or is it required to setup a web server to host the audio? Any input you may have on this would be very much appreciated.
Thanks!