案例:我哋點樣用共享快取將 AI 語音成本壓到最低
簡單答:AceSpeller 用雲端 AI 語音讀出默書內容,每生成一段語音都要俾錢。我哋設計咗兩層快取:第一層喺用戶自己部手機,第二層喺雲端、所有用戶共享。同一段字、同一把聲、同一個設定,只會向 AI 服務生成一次,之後所有用戶都直接用返。結果係用戶越多,命中快取嘅機會越高,平均每次讀出嘅成本越低。
要解決嘅問題
小朋友默書會重複聽好多次,而唔同學校、唔同家長,好多時默緊同一啲詞語。如果每次都叫 AI 重新生成語音,成本會隨用量直線上升,亦要等。
兩層快取點運作
- 手機本機快取:App 先睇自己部手機有冇存過呢段語音。有就即刻播放,唔使上網,唔使錢。
- 雲端共享快取:手機冇,就問我哋嘅雲端服務。雲端會先睇共享儲存有冇其他用戶之前生成過一模一樣嘅語音,有就直接傳返嚟。
- 真正生成:兩層都冇,先會向 AI 語音服務生成,生成完存入共享儲存,再傳返手機存一份。
判斷「一模一樣」嘅方法,係將文字、聲音、語速等所有會影響語音嘅設定,計成一個唯一嘅識別碼。設定一樣,識別碼就一樣,就可以共用。
點樣提高命中率
- 統一設定:朗讀文章功能固定聲音同語速,唔俾隨意拉,令所有用戶產生同一個識別碼,共用機會大好多。
- 整理文字:生成前先統一空白同格式,避免「多咗一個空格」就當成唔同內容。
- 同篇去重:同一篇文章入面重複嘅句子只生成一次。
- 預先生成:App 內置嘅範例文章,我哋預先生成好語音,用戶第一次撳都即刻有聲。
另外雲端服務設咗使用上限,避免有人大量濫用,成本唔會失控。
一次真實教訓:快取靜靜雞失效
有一段時間,我哋改咗雲端服務嘅設定,漏咗指定共享儲存嘅位置。App 照樣正常讀出語音,用戶完全察覺唔到,但其實每次都重新生成,共享快取冇發揮作用。直到我哋做升級測試、睇系統紀錄,先發現問題,修正之後,紀錄重新出現「已存入快取」同「命中快取」。
教訓係:快取出事唔會報錯,只會靜靜雞令成本上升。所以要定期睇紀錄,確認快取真係有命中。
呢套做法點樣用落公司項目
- 重複嘅 AI 處理:同一份文件、同一張單,唔好處理兩次,結果存低重用。
- 統一輸入:輸入格式越統一,越容易重用結果。
- 設上限:每日或每小時用量上限,避免出錯或者濫用時成本失控。
- 睇紀錄:定期檢查用量同命中率,唔好等收到帳單先知。
AI 服務嘅使用費點計,可以睇《香港中小企 AI 自動化要幾錢?》;AceSpeller 另一個功能嘅案例,可以睇《AceSpeller 點樣將默書表相片變成練習》。
自己做最常卡喺邊?
- 唔知點樣判斷兩次請求係咪「一模一樣」,結果快取幾乎冇命中
- 快取存喺邊、保留幾耐、點樣清,冇諗清楚
- 快取失效都唔知,月尾收到帳單先發現
- 冇設使用上限,一個錯誤令 AI 服務被大量呼叫
以上任何一樣卡住咗,都可以搵我哋。簽約前免費諮詢,我哋會直接話你知要做乜、大概幾錢。
我哋可以點幫你
AceSpeller 由設計、開發、上架到營運都係我哋自己做,包括呢套快取。同樣嘅做法,我哋用嚟幫公司做 AI 流程自動化(單一流程 HK$5,000 起)、AI 工具/程式開發(HK$8,000 起)同手機 App 開發(標準 App HK$30,000 起)。所有套餐可以睇套餐同價錢,或者直接同我哋傾一次,簽約前免費諮詢。
Case study: how a shared cache keeps our AI voice costs down
The short answer: AceSpeller uses cloud AI voices to read dictation content aloud, and every clip generated costs money. We built two layers of cache: one on each user's own phone, and one in the cloud shared by every user. The same text, voice and settings are generated by the AI service only once; after that, every user reuses the result. The more users there are, the more often the cache is hit, and the lower the average cost of each playback.
The problem
Children listen to dictation many times, and different schools and parents are often practising the same words. If the AI regenerated the audio every time, costs would rise in a straight line with usage, and users would have to wait.
How the two layers work
- On-device cache: the app first checks whether the phone already has this clip. If so, it plays immediately, with no network and no cost.
- Shared cloud cache: if not, the app asks our cloud service, which checks shared storage for an identical clip generated earlier by any user, and sends it back if found.
- Actual generation: only when neither layer has it do we ask the AI voice service to generate it. The result is saved to shared storage and sent to the phone, which keeps a copy.
"Identical" is decided by turning the text, voice, speed and every other setting that affects the audio into a single unique key. Same settings, same key, so the clip can be shared.
How we raise the hit rate
- Fixed settings: the article reading feature uses a fixed voice and speed rather than a slider, so all users produce the same key and sharing becomes far more likely.
- Tidy the text: spacing and formatting are normalised before generation, so an extra space does not count as different content.
- De-duplicate within an article: a sentence repeated in the same article is generated only once.
- Generate in advance: we pre-generate audio for the built-in sample articles, so they play instantly even the first time.
The cloud service also has usage limits, so heavy misuse cannot make costs run away.
A real lesson: the cache quietly stopped working
For a period, a change to our cloud service's configuration left out where the shared storage was. The app still played audio normally and users noticed nothing, but every clip was being regenerated and the shared cache was doing nothing. We only found it during upgrade testing, by reading the system logs. Once fixed, the logs again showed clips being saved to and served from the cache.
The lesson: a broken cache does not raise an error; it just quietly raises costs. Check the logs regularly to confirm the cache is really being hit.
Applying this to business projects
- Repeated AI processing: do not process the same document or receipt twice; store and reuse the result.
- Consistent inputs: the more consistent the input format, the easier results are to reuse.
- Set limits: daily or hourly usage caps stop costs running away when something goes wrong or is misused.
- Read the logs: check usage and hit rates regularly instead of finding out from the bill.
For how AI usage fees work, see How much does AI automation cost for Hong Kong SMEs?. For another AceSpeller case study, see How AceSpeller turns a photo of a dictation list into practice.
Where do people usually get stuck?
- Not knowing how to decide whether two requests are "identical", so the cache is almost never hit
- Not having thought through where the cache lives, how long it is kept and how it is cleared
- The cache stops working and nobody notices until the bill arrives
- No usage limit, so a single bug triggers huge numbers of AI calls
If any of these is where you are stuck, talk to us. Consultation before signing is free, and we will tell you plainly what needs doing and roughly what it costs.
How we can help
We design, build, publish and run AceSpeller ourselves, this cache included. We bring the same approach to companies through AI workflow automation (single workflows from HK$5,000), AI tools and software (from HK$8,000) and mobile app development (standard apps from HK$30,000). See all packages and pricing, or talk to us: consultation before signing is free.