Fix: use fish-audio-sdk (not fishaudio), correct import
This commit is contained in:
10
ingest.py
10
ingest.py
@@ -109,18 +109,18 @@ def transcribe_chunk_fish(chunk_path, api_key, start_offset_sec):
|
|||||||
Returns a list of segments with timestamps adjusted by start_offset_sec.
|
Returns a list of segments with timestamps adjusted by start_offset_sec.
|
||||||
Note: Fish Audio returns timestamps in milliseconds.
|
Note: Fish Audio returns timestamps in milliseconds.
|
||||||
"""
|
"""
|
||||||
from fishaudio import FishAudio
|
from fish_audio_sdk import Session, ASRRequest
|
||||||
|
|
||||||
print(f" → Fish Audio ASR: {chunk_path.name} (offset +{start_offset_sec}s)", flush=True)
|
print(f" → Fish Audio ASR: {chunk_path.name} (offset +{start_offset_sec}s)", flush=True)
|
||||||
|
|
||||||
client = FishAudio(api_key=api_key)
|
with Session(api_key) as session:
|
||||||
with open(chunk_path, "rb") as f:
|
with open(chunk_path, "rb") as f:
|
||||||
result = client.asr.transcribe(audio=f.read(), language="en")
|
result = session.asr(ASRRequest(audio=f.read(), language="en"))
|
||||||
|
|
||||||
# Fish Audio returns timestamps in milliseconds — convert to seconds
|
# Fish Audio returns timestamps in milliseconds — convert to seconds
|
||||||
# and adjust by the chunk's start offset in the full audio
|
# and adjust by the chunk's start offset in the full audio
|
||||||
segments = []
|
segments = []
|
||||||
for seg in result.segments:
|
for seg in (result.segments or []):
|
||||||
segments.append({
|
segments.append({
|
||||||
"start": seg.start / 1000.0 + start_offset_sec,
|
"start": seg.start / 1000.0 + start_offset_sec,
|
||||||
"end": seg.end / 1000.0 + start_offset_sec,
|
"end": seg.end / 1000.0 + start_offset_sec,
|
||||||
@@ -128,7 +128,7 @@ def transcribe_chunk_fish(chunk_path, api_key, start_offset_sec):
|
|||||||
})
|
})
|
||||||
|
|
||||||
# Fallback: if no segments, use full text as one block
|
# Fallback: if no segments, use full text as one block
|
||||||
if not segments and result.text:
|
if not segments and getattr(result, "text", None):
|
||||||
segments.append({
|
segments.append({
|
||||||
"start": start_offset_sec,
|
"start": start_offset_sec,
|
||||||
"end": start_offset_sec + 60,
|
"end": start_offset_sec + 60,
|
||||||
|
|||||||
Reference in New Issue
Block a user