Spaces:
Runtime error
Runtime error
Peter Michael Gits Claude commited on
Commit ·
ac6f784
1
Parent(s): 9201e6d
Fix NumPy array writable warning in audio processing
Browse filesv1.4.2 - Minor fix: PyTorch non-writable tensor warning
- Added .copy() to audio_data before torch.from_numpy()
- Prevents: 'PyTorch does not support non-writable tensors' warning
- Improves memory safety during audio tensor conversion
- CPU transcription working well with client connections
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
app.py
CHANGED
|
@@ -21,7 +21,7 @@ from fastapi.responses import JSONResponse, HTMLResponse
|
|
| 21 |
import uvicorn
|
| 22 |
|
| 23 |
# Version tracking
|
| 24 |
-
VERSION = "1.4.
|
| 25 |
COMMIT_SHA = "TBD"
|
| 26 |
|
| 27 |
# Configure logging
|
|
@@ -137,7 +137,8 @@ def transcribe_audio_moshi(audio_data: np.ndarray, sample_rate: int = 24000) ->
|
|
| 137 |
logger.info(f"Using device for transcription: {model_device}")
|
| 138 |
|
| 139 |
# Convert to torch tensor and put on same device as models
|
| 140 |
-
|
|
|
|
| 141 |
|
| 142 |
# Process with Mimi codec in streaming mode
|
| 143 |
with torch.no_grad(), mimi.streaming(batch_size=1):
|
|
|
|
| 21 |
import uvicorn
|
| 22 |
|
| 23 |
# Version tracking
|
| 24 |
+
VERSION = "1.4.2"
|
| 25 |
COMMIT_SHA = "TBD"
|
| 26 |
|
| 27 |
# Configure logging
|
|
|
|
| 137 |
logger.info(f"Using device for transcription: {model_device}")
|
| 138 |
|
| 139 |
# Convert to torch tensor and put on same device as models
|
| 140 |
+
# Copy array to avoid PyTorch writable tensor warning
|
| 141 |
+
wav = torch.from_numpy(audio_data.copy()).unsqueeze(0).unsqueeze(0).to(model_device)
|
| 142 |
|
| 143 |
# Process with Mimi codec in streaming mode
|
| 144 |
with torch.no_grad(), mimi.streaming(batch_size=1):
|