Background
There are legal concerns with providing an open API that acts as a proxy to Google's Cloud API. For this reason, along with a few advantages, we want to do all the processing when the page is parsed, similar to how Extension:Score works. Then we wouldn't need an API at all. We're already using the onParserFirstCallInit now, but the HTML is completely rebuilt client-side and the file is never generated until something is clicked.
In a separate ticket T315482: Generate HTML server side for IPA audio button, we will explore moving the HTML construction to the backend and out of PhonosButton.js, which would then keep it all in one place.
Advantages to bypassing our API and saving the files on parse:
- Quicker load time for playing the audio, since it's already saved
Non-JavaScript users are supported (the button simply links to the file)(after T315482 is resolved)- Our cache key still persists even when the page is re-parsed, meaning there are no unnecessary API calls (unless the parameters to the Phonos parser function changed)
Other considerations
- The rollout to production when the parent IPA template is changed to use Phonos could cause a massive amount of API calls to Google at once (since all pages using that template will get re-parsed). We should be careful to deploy slowly and ensure we aren't hitting any throttling limits or the like.
- Re-parsing quickly, such as when fiddling with Phonos using Realtime Preview, will cause a unique call to Google each time as well as creating a new file. However if the above bullet is not a concern, this shouldn't be either!
- There will be a slight performance hit to saving edits when we need to generate new audio.
Acceptance criteria
- Change the backend and frontend so that deal with URLs, not base64 audio.
- The Engine should be called from this code, so that we have always have a full URL to give to PhonosButton.js.
- PhonosButton.js can still be responsible for constructing HTML and playing the audio as it does now.
- Visual acceptance criteria is basically nil. Nothing should look or act different; only that clicking Play will seem a bit faster and initial previews might be a little slow depending on how much Phonos usage there is on the page.