feat(api): use Tencent 16k_zh_large ASR and remove local Whisper
Standardize ASR on Tencent's dialect-capable engine across all environments, drop faster-whisper from dependencies and deployment images, and add an expo-sqlite iOS vendor sync plus pod install in prebuild to prevent native build failures after npm install. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,13 +4,14 @@
|
||||
"version": "1.2.0",
|
||||
"scripts": {
|
||||
"use-env": "node scripts/use-env.js",
|
||||
"postinstall": "node scripts/ensure-expo-sqlite-ios.js",
|
||||
"prestart": "npm run use-env -- development",
|
||||
"start": "expo start",
|
||||
"start:staging": "npm run use-env -- staging && expo start",
|
||||
"start:prod": "npm run use-env -- production && expo start",
|
||||
"reset-project": "node ./scripts/reset-project.js",
|
||||
"android": "npm run use-env -- development && expo run:android",
|
||||
"ios": "npm run use-env -- development && expo run:ios",
|
||||
"ios": "npm run use-env -- development && node scripts/ensure-expo-sqlite-ios.js && expo run:ios",
|
||||
"ios:prebuild": "bash scripts/ios-prebuild.sh staging",
|
||||
"ios:prebuild:staging": "bash scripts/ios-prebuild.sh staging",
|
||||
"ios:prebuild:production": "bash scripts/ios-prebuild.sh production",
|
||||
|
||||
51
app-expo/scripts/ensure-expo-sqlite-ios.js
Normal file
51
app-expo/scripts/ensure-expo-sqlite-ios.js
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* expo-sqlite copies vendor/sqlite3/*.c into ios/ during `pod install` (see ExpoSQLite.podspec).
|
||||
* After a fresh `npm install`, Xcode can fail with missing sqlite3.c until pods run.
|
||||
* This script mirrors that copy so native builds work without an extra manual step.
|
||||
*/
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const appRoot = path.join(__dirname, '..');
|
||||
const pkgRoot = path.join(appRoot, 'node_modules', 'expo-sqlite');
|
||||
|
||||
function readUseLibSQL() {
|
||||
const propsPath = path.join(appRoot, 'ios', 'Podfile.properties.json');
|
||||
if (!fs.existsSync(propsPath)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
const props = JSON.parse(fs.readFileSync(propsPath, 'utf8'));
|
||||
return props['expo.sqlite.useLibSQL'] === 'true';
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
if (!fs.existsSync(pkgRoot)) {
|
||||
return;
|
||||
}
|
||||
if (readUseLibSQL()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const vendorDir = path.join(pkgRoot, 'vendor', 'sqlite3');
|
||||
const iosDir = path.join(pkgRoot, 'ios');
|
||||
for (const file of ['sqlite3.c', 'sqlite3.h']) {
|
||||
const src = path.join(vendorDir, file);
|
||||
const dest = path.join(iosDir, file);
|
||||
if (!fs.existsSync(src)) {
|
||||
console.warn(`[ensure-expo-sqlite-ios] missing vendor file: ${src}`);
|
||||
continue;
|
||||
}
|
||||
if (fs.existsSync(dest)) {
|
||||
continue;
|
||||
}
|
||||
fs.mkdirSync(iosDir, { recursive: true });
|
||||
fs.copyFileSync(src, dest);
|
||||
console.log(`[ensure-expo-sqlite-ios] copied ${file} -> ios/`);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -47,6 +47,10 @@ done
|
||||
echo "==> expo prebuild --platform ios --clean"
|
||||
npx expo prebuild --platform ios --clean
|
||||
|
||||
echo "==> ensure expo-sqlite native sources + pod install"
|
||||
node scripts/ensure-expo-sqlite-ios.js
|
||||
(cd ios && pod install)
|
||||
|
||||
shopt -s nullglob
|
||||
WORKSPACES=(ios/*.xcworkspace)
|
||||
shopt -u nullglob
|
||||
|
||||
@@ -18,8 +18,8 @@ type StatusListener = (status: RecorderStatus) => void;
|
||||
type RecordingCompleteListener = (uri: string, durationMs: number) => void;
|
||||
|
||||
/**
|
||||
* Tencent SentenceRecognition is currently called with `EngSerViceType=16k_zh`
|
||||
* and `VoiceFormat=m4a`, so record speech in that shape directly instead of
|
||||
* Tencent SentenceRecognition uses `EngSerViceType=16k_zh_large` and
|
||||
* `VoiceFormat=m4a`, so record speech in that shape directly instead of
|
||||
* relying on Expo's default 44.1 kHz stereo preset.
|
||||
*/
|
||||
export const VOICE_RECORDING_OPTIONS: RecordingOptions = {
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
} from '@/features/voice/recorder';
|
||||
|
||||
describe('buildVoiceRecordingOptions', () => {
|
||||
test('uses 16 kHz mono m4a recording options for Tencent-compatible speech capture', () => {
|
||||
test('uses 16 kHz mono m4a recording options for Tencent 16k_zh_large capture', () => {
|
||||
const passedOptions = buildVoiceRecordingOptions();
|
||||
|
||||
expect(passedOptions).toEqual(
|
||||
|
||||
Reference in New Issue
Block a user