Spaces:
Runtime error
Runtime error
Update app/main.py
Browse files- app/main.py +8 -7
app/main.py
CHANGED
|
@@ -29,25 +29,26 @@ print("[BOOT] Model loaded")
|
|
| 29 |
app = FastAPI(title="LFM2.5 Speech-to-Speech", version="3.0")
|
| 30 |
|
| 31 |
|
| 32 |
-
def wav_header(
|
| 33 |
-
byte_rate =
|
| 34 |
-
block_align =
|
| 35 |
return (
|
| 36 |
b"RIFF"
|
| 37 |
-
+ b"\xff\xff\xff\xff"
|
| 38 |
+ b"WAVEfmt "
|
| 39 |
+ (16).to_bytes(4, "little")
|
| 40 |
+ (1).to_bytes(2, "little")
|
| 41 |
-
+
|
| 42 |
-
+
|
| 43 |
+ byte_rate.to_bytes(4, "little")
|
| 44 |
+ block_align.to_bytes(2, "little")
|
| 45 |
+ bits.to_bytes(2, "little")
|
| 46 |
+ b"data"
|
| 47 |
-
+ b"\xff\xff\xff\xff"
|
| 48 |
)
|
| 49 |
|
| 50 |
|
|
|
|
| 51 |
async def generate_response(websocket: WebSocket, audio_np: np.ndarray):
|
| 52 |
|
| 53 |
chat = ChatState(processor)
|
|
|
|
| 29 |
app = FastAPI(title="LFM2.5 Speech-to-Speech", version="3.0")
|
| 30 |
|
| 31 |
|
| 32 |
+
def wav_header(sample_rate: int, channels: int = 1, bits: int = 16) -> bytes:
|
| 33 |
+
byte_rate = sample_rate * channels * bits // 8
|
| 34 |
+
block_align = channels * bits // 8
|
| 35 |
return (
|
| 36 |
b"RIFF"
|
| 37 |
+
+ (b"\xff\xff\xff\xff")
|
| 38 |
+ b"WAVEfmt "
|
| 39 |
+ (16).to_bytes(4, "little")
|
| 40 |
+ (1).to_bytes(2, "little")
|
| 41 |
+
+ channels.to_bytes(2, "little")
|
| 42 |
+
+ sample_rate.to_bytes(4, "little")
|
| 43 |
+ byte_rate.to_bytes(4, "little")
|
| 44 |
+ block_align.to_bytes(2, "little")
|
| 45 |
+ bits.to_bytes(2, "little")
|
| 46 |
+ b"data"
|
| 47 |
+
+ (b"\xff\xff\xff\xff")
|
| 48 |
)
|
| 49 |
|
| 50 |
|
| 51 |
+
|
| 52 |
async def generate_response(websocket: WebSocket, audio_np: np.ndarray):
|
| 53 |
|
| 54 |
chat = ChatState(processor)
|