use fun-asr-nano model instead

This commit is contained in:
2026-06-02 20:24:31 -07:00
parent 3e50191530
commit 40a4274fd3
6 changed files with 38 additions and 11 deletions
+3 -3
View File
@@ -69,8 +69,8 @@ The checked-in `docker-compose.yml` mounts local `./config.toml` there for the A
## Services And Ports ## Services And Ports
- Frontend: `http://localhost:3000` - Frontend: `http://localhost:3000`
- Backend API: `http://localhost:8080` - Backend API: `http://localhost:8081`
- API docs: `http://localhost:8080/docs` - API docs: `http://localhost:8081/docs`
- Redis: `localhost:6379` when exposed by Compose - Redis: `localhost:6379` when exposed by Compose
- PostgreSQL: only started by Compose when using the `local-db` profile - PostgreSQL: only started by Compose when using the `local-db` profile
@@ -145,7 +145,7 @@ The frontend reads the backend URL from `frontend/public/config.js` at runtime:
```js ```js
window.__EVANESCERE_FRONTEND_CONFIG__ = { window.__EVANESCERE_FRONTEND_CONFIG__ = {
apiBaseUrl: "http://192.168.1.44:8080" apiBaseUrl: "http://192.168.1.44:8081"
}; };
``` ```
+1 -1
View File
@@ -10,7 +10,7 @@ services:
build: . build: .
command: uvicorn evanescere.api:app --host 0.0.0.0 --port 8000 command: uvicorn evanescere.api:app --host 0.0.0.0 --port 8000
ports: ports:
- "8080:8000" - "8081:8000"
volumes: volumes:
- ./config.toml:/etc/evanescere/config.toml:ro - ./config.toml:/etc/evanescere/config.toml:ro
- ./storage:/data/evanescere - ./storage:/data/evanescere
+1 -1
View File
@@ -1,3 +1,3 @@
window.__EVANESCERE_FRONTEND_CONFIG__ = { window.__EVANESCERE_FRONTEND_CONFIG__ = {
apiBaseUrl: "http://192.168.1.44:8080" apiBaseUrl: "http://192.168.1.44:8081"
}; };
+1 -1
View File
@@ -9,7 +9,7 @@ import type {
const runtimeApiBase = window.__EVANESCERE_FRONTEND_CONFIG__?.apiBaseUrl; const runtimeApiBase = window.__EVANESCERE_FRONTEND_CONFIG__?.apiBaseUrl;
export const apiBaseUrl = (runtimeApiBase || "http://localhost:8080").replace( export const apiBaseUrl = (runtimeApiBase || "http://localhost:8081").replace(
/\/$/, /\/$/,
"", "",
); );
+16 -5
View File
@@ -35,7 +35,7 @@ class FunAsrClient:
"model": self.model, "model": self.model,
"language": "zh", "language": "zh",
"response_format": "verbose_json", "response_format": "verbose_json",
"timestamp_granularities[]": "segment", "timestamp_granularities": "segment",
}, },
files={"file": (audio_path.name, audio_file, "audio/wav")}, files={"file": (audio_path.name, audio_file, "audio/wav")},
timeout=None, timeout=None,
@@ -45,8 +45,12 @@ class FunAsrClient:
logger.info("funasr request done audio=%s keys=%s", audio_path, sorted(payload.keys())) logger.info("funasr request done audio=%s keys=%s", audio_path, sorted(payload.keys()))
return payload return payload
def normalize_segments(
def normalize_segments(payload: dict[str, Any]) -> list[dict[str, Any]]: payload: dict[str, Any],
*,
fallback_start_sec: float = 0.0,
fallback_end_sec: float | None = None,
) -> list[dict[str, Any]]:
raw_segments = payload.get("segments") or payload.get("sentence_info") or [] raw_segments = payload.get("segments") or payload.get("sentence_info") or []
logger.debug("normalizing asr segments raw_count=%s", len(raw_segments)) logger.debug("normalizing asr segments raw_count=%s", len(raw_segments))
normalized: list[dict[str, Any]] = [] normalized: list[dict[str, Any]] = []
@@ -71,10 +75,17 @@ def normalize_segments(payload: dict[str, Any]) -> list[dict[str, Any]]:
} }
) )
if not normalized and payload.get("text"): if not normalized and payload.get("text"):
logger.warning(
"asr response contained text but no timestamped segments; "
"falling back to the known audio bounds"
)
end_sec = fallback_end_sec
if end_sec is None:
end_sec = float(payload.get("duration") or fallback_start_sec + 0.1)
normalized.append( normalized.append(
{ {
"start_sec": 0.0, "start_sec": fallback_start_sec,
"end_sec": 0.1, "end_sec": max(fallback_start_sec + 0.1, end_sec),
"text": str(payload["text"]).strip(), "text": str(payload["text"]).strip(),
"speaker": None, "speaker": None,
"confidence": None, "confidence": None,
+16
View File
@@ -0,0 +1,16 @@
from evanescere.services.asr import normalize_segments
def test_normalize_segments_uses_known_audio_bounds_when_timestamps_are_missing():
assert normalize_segments(
{"text": "你好", "segments": []}, fallback_start_sec=0, fallback_end_sec=15
) == [
{
"start_sec": 0,
"end_sec": 15,
"text": "你好",
"speaker": None,
"confidence": None,
"metadata": {"text": "你好", "segments": []},
}
]