feat(items): voice dictation with Gemma 4 and a reworked list UI
Dictation: a mic button in the add field uses the Web Speech API (es-AR) and
shows the partial transcript in the input. POST /api/voice/split asks Gemma 4
(Gemini API, plain fetch) to split the sentence into one string per item,
written the way the existing parser reads typed text; each string then goes
through the usual add flow. The endpoint never fails because of the model:
missing key, timeout, 429 or invalid JSON fall back to splitting on commas,
semicolons, " y " and " e ". A toast offers "Deshacer" for the whole dictation;
if the request fails, the transcript is added as a single item.
UI: "+" instead of the search icon, quantity tags ("2 L", "×12", "1 kg"), the
list name with a list switcher and the pending/bought count in the header,
"Comprados (N)" folded by default, and a bottom sheet to edit name, quantity
(− / + and unit), note and delete. PATCH items now accepts a name.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
23
apps/api/src/modules/voice/split/route.ts
Normal file
23
apps/api/src/modules/voice/split/route.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Hono } from 'hono'
|
||||
|
||||
import { requireSession } from '@/lib/auth-session'
|
||||
import { GeminiClient } from '@/lib/gemini'
|
||||
import { resultJson } from '@/lib/result-json'
|
||||
import { validate } from '@/lib/validate'
|
||||
import type { AppEnv } from '@/types'
|
||||
|
||||
import { SplitVoiceSchema } from './schema'
|
||||
import { SplitVoiceText } from './use-case'
|
||||
|
||||
/** POST /voice/split — splits a dictated sentence into one string per item. */
|
||||
export const splitVoiceRoute = new Hono<AppEnv>().post(
|
||||
'/split',
|
||||
requireSession,
|
||||
validate.json(SplitVoiceSchema),
|
||||
async (c) => {
|
||||
const { text } = c.req.valid('json')
|
||||
const result = await new SplitVoiceText(new GeminiClient(), c.get('logger')).execute({ text })
|
||||
|
||||
return resultJson(c, result)
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user