From db124860ed219ec33d97dc8a307c2fb515e55c5f Mon Sep 17 00:00:00 2001 From: Abe Jellinek <1770299+AbeJellinek@users.noreply.github.com> Date: Tue, 3 Mar 2026 15:40:35 -0500 Subject: [PATCH] Read Aloud: Use POST for /speak --- .../zotero/xpcom/sync/syncAPIClient.js | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/chrome/content/zotero/xpcom/sync/syncAPIClient.js b/chrome/content/zotero/xpcom/sync/syncAPIClient.js index 2f02799040..27ee65cd92 100644 --- a/chrome/content/zotero/xpcom/sync/syncAPIClient.js +++ b/chrome/content/zotero/xpcom/sync/syncAPIClient.js @@ -601,25 +601,32 @@ Zotero.Sync.APIClient.prototype = { async getReadAloudAudio(segment, voiceID) { + let method; let url; - let params = new URLSearchParams(); + let options = { + responseType: "blob", + errorDelayMax: 8000, + }; if (segment === 'sample') { - url = this.baseURL + "tts/sample"; + method = "GET"; + let params = new URLSearchParams(); + params.set('voice', voiceID); + url = this.baseURL + "tts/sample?" + params; + options.noAPIKey = true; } else { + method = "POST"; url = this.baseURL + "tts/speak"; - params.set('text', segment.text); - } - params.set('voice', voiceID); - let uri = url + "?" + params; - try { - let xmlhttp = await this.makeRequest("GET", uri, { - responseType: "blob", - noAPIKey: segment === 'sample', - cache: true, - errorDelayMax: 8000, + options.headers = { + "Content-Type": "application/json", + }; + options.body = JSON.stringify({ + voice: voiceID, + text: segment.text, }); - + } + try { + let xmlhttp = await this.makeRequest(method, url, options); return { audio: xmlhttp.response }; } catch (e) {