mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-02-07 01:11:22 +08:00
ggwave-to-file : update python example to be PEP8 compliant.
Update README.md
This commit is contained in:
committed by
Georgi Gerganov
parent
9c4f610751
commit
3aeb7c0b1f
@@ -85,20 +85,26 @@ curl -sS 'https://ggwave-to-file.ggerganov.com/?m=Hello world!&p=4' --output hel
|
||||
### python
|
||||
|
||||
```python
|
||||
from typing import Dict, Union
|
||||
import requests
|
||||
import wave
|
||||
|
||||
|
||||
def ggwave(message: str, file: str, protocolId: int = 1, sampleRate: float = 48000, volume: int = 50, payloadLength: int = -1):
|
||||
def ggwave(message: str,
|
||||
file: str,
|
||||
protocolId: int = 1,
|
||||
sampleRate: float = 48000,
|
||||
volume: int = 50,
|
||||
payloadLength: int = -1) -> None:
|
||||
|
||||
url = 'https://ggwave-to-file.ggerganov.com/'
|
||||
|
||||
params = {
|
||||
'm': message, # message to encode
|
||||
'p': protocolId, # transmission protocol to use
|
||||
's': sampleRate, # output sample rate
|
||||
'v': volume, # output volume
|
||||
'l': payloadLength, # if positive - use fixed-length encoding
|
||||
params: Dict[str, Union[str, int, float] = {
|
||||
'm': message, # message to encode
|
||||
'p': protocolId, # transmission protocol to use
|
||||
's': sampleRate, # output sample rate
|
||||
'v': volume, # output volume
|
||||
'l': payloadLength, # if positive - use fixed-length encoding
|
||||
}
|
||||
|
||||
response = requests.get(url, params=params)
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
from typing import Dict, Union
|
||||
import requests
|
||||
import wave
|
||||
|
||||
|
||||
def ggwave(message: str, file: str, protocolId: int = 1, sampleRate: float = 48000, volume: int = 50, payloadLength: int = -1) -> None:
|
||||
def ggwave(message: str,
|
||||
file: str,
|
||||
protocolId: int = 1,
|
||||
sampleRate: float = 48000,
|
||||
volume: int = 50,
|
||||
payloadLength: int = -1) -> None:
|
||||
|
||||
url = 'https://ggwave-to-file.ggerganov.com/'
|
||||
|
||||
params = {
|
||||
'm': message, # message to encode
|
||||
'p': protocolId, # transmission protocol to use
|
||||
's': sampleRate, # output sample rate
|
||||
'v': volume, # output volume
|
||||
'l': payloadLength, # if positive - use fixed-length encoding
|
||||
params: Dict[str, Union[str, int, float]] = {
|
||||
'm': message, # message to encode
|
||||
'p': protocolId, # transmission protocol to use
|
||||
's': sampleRate, # output sample rate
|
||||
'v': volume, # output volume
|
||||
'l': payloadLength, # if positive - use fixed-length encoding
|
||||
}
|
||||
|
||||
response = requests.get(url, params=params)
|
||||
|
||||
Reference in New Issue
Block a user