Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ sudo apt install libopus-dev

# Fedora/RHEL
sudo dnf install opus-devel

# macOS (Homebrew)
brew install opus
```

### Installation
Expand All @@ -46,6 +49,26 @@ Then set up your Huggingface authentication:
export HF_TOKEN=<YOUR_HUGGINGFACE_TOKEN>
```

### Device Selection

`moshi.server` now auto-selects `cuda`, then `mps`, then `cpu`.

On Apple Silicon, you can also force Metal explicitly:
```bash
SSL_DIR=$(mktemp -d); python -m moshi.server --ssl "$SSL_DIR" --device mps
```

`moshi.offline` accepts the same `--device` flag, for example:
```bash
python -m moshi.offline --device mps \
--voice-prompt "NATF2.pt" \
--input-wav "assets/test/input_assistant.wav" \
--output-wav "output.wav" \
--output-text "output.json"
```

Note: MPS support depends on the local PyTorch build and Apple Metal support available on the host machine.

### Launch Server

Launch server for live interaction (temporary SSL certs for https):
Expand Down
6 changes: 3 additions & 3 deletions moshi/moshi/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@


logger = setup_logger(__name__)
DeviceString = Literal["cuda"] | Literal["cpu"] #| Literal["mps"]
DeviceString = Literal["cuda"] | Literal["cpu"] | Literal["mps"]

def torch_auto_device(requested: Optional[DeviceString] = None) -> torch.device:
"""Return a torch.device based on the requested string or availability."""
if requested is not None:
return torch.device(requested)
if torch.cuda.is_available():
return torch.device("cuda")
#elif hasattr(torch.backends, "mps") and torch.backends.mps.is_available():
# return torch.device("mps")
if hasattr(torch.backends, "mps") and torch.backends.mps.is_available():
return torch.device("mps")
return torch.device("cpu")


Expand Down