Skip to content

Commit db1dcac

Browse files
Merge pull request #206 from deepgram/dyv-experiment-v3
Fix Dynamic Loading of PyAudio
2 parents 9e85f25 + 536831f commit db1dcac

File tree

20 files changed

+199
-969
lines changed

20 files changed

+199
-969
lines changed

.gitignore

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
*.egg-info
2-
__pycache__
3-
dist/
1+
# general
2+
3+
# environment artifacts
44
.venv
55
.env
66
venv/
77
venv.bak/
8+
.vscode/
9+
10+
# python artifacts
11+
__pycache__
12+
*.egg-info
13+
dist/
14+
15+
# build
816
build/
9-
.vscode/
17+
poetry.lock

deepgram/__init__.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,33 @@
66
__version__ = "0.0.0"
77

88
# entry point for the deepgram python sdk
9-
from .client import DeepgramClient, DeepgramApiKeyError
9+
from .client import DeepgramClient
1010
from .options import DeepgramClientOptions
1111

1212
# live
13-
from .clients.live.enums import LiveTranscriptionEvents
14-
from .clients.live.client import LiveClient, AsyncLiveClient, LiveOptions
13+
from .clients import LiveTranscriptionEvents
14+
from .clients import LiveClient, AsyncLiveClient, LiveOptions
1515

1616
# onprem
17-
from .clients.onprem.client import (
17+
from .clients import (
1818
OnPremClient,
1919
AsyncOnPremClient,
2020
)
2121

2222
# prerecorded
23-
from .clients.prerecorded.client import (
23+
from .clients import (
2424
PreRecordedClient,
2525
AsyncPreRecordedClient,
2626
PrerecordedOptions,
2727
PrerecordedSource,
2828
FileSource,
2929
UrlSource,
30+
BufferSource,
31+
ReadStreamSource,
3032
)
3133

3234
# manage
33-
from .clients.manage.client import (
35+
from .clients import (
3436
ManageClient,
3537
AsyncManageClient,
3638
ProjectOptions,
@@ -43,4 +45,10 @@
4345
)
4446

4547
# utilities
46-
from .audio.microphone.microphone import Microphone
48+
from .audio import Microphone
49+
from .audio import (
50+
LOGGING,
51+
CHANNELS,
52+
RATE,
53+
CHUNK,
54+
)

deepgram/audio/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright 2023 Deepgram SDK contributors. All Rights Reserved.
2+
# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
3+
# SPDX-License-Identifier: MIT
4+
5+
from .microphone import Microphone
6+
from .microphone import LOGGING, CHANNELS, RATE, CHUNK
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright 2023 Deepgram SDK contributors. All Rights Reserved.
2+
# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
3+
# SPDX-License-Identifier: MIT
4+
5+
from .microphone import Microphone
6+
from .constants import LOGGING, CHANNELS, RATE, CHUNK
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright 2023 Deepgram SDK contributors. All Rights Reserved.
2+
# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
3+
# SPDX-License-Identifier: MIT
4+
5+
import logging, verboselogs
6+
7+
LOGGING = logging.WARNING
8+
CHANNELS = 1
9+
RATE = 16000
10+
CHUNK = 8194

deepgram/audio/microphone/microphone.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@
55
import inspect
66
import asyncio
77
import threading
8-
import pyaudio
98
from array import array
109
import logging, verboselogs
1110

1211
from .errors import DeepgramMicrophoneError
13-
14-
FORMAT = pyaudio.paInt16
15-
CHANNELS = 1
16-
RATE = 16000
17-
CHUNK = 8194
12+
from .constants import LOGGING, CHANNELS, RATE, CHUNK
1813

1914

2015
class Microphone:
@@ -25,20 +20,21 @@ class Microphone:
2520
def __init__(
2621
self,
2722
push_callback,
28-
verbose=logging.WARNING,
29-
format=FORMAT,
23+
verbose=LOGGING,
3024
rate=RATE,
3125
chunk=CHUNK,
3226
channels=CHANNELS,
3327
):
28+
import pyaudio
29+
3430
self.logger = logging.getLogger(__name__)
3531
self.logger.addHandler(logging.StreamHandler())
3632
self.logger.setLevel(verbose)
3733

3834
self.audio = pyaudio.PyAudio()
3935
self.chunk = chunk
4036
self.rate = rate
41-
self.format = format
37+
self.format = pyaudio.paInt16
4238
self.channels = channels
4339
self.push_callback = push_callback
4440
self.stream = None

deepgram/clients/__init__.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2023 Deepgram SDK contributors. All Rights Reserved.
2+
# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
3+
# SPDX-License-Identifier: MIT
4+
5+
# live
6+
from .live import LiveClient
7+
from .live import AsyncLiveClient
8+
from .live import LiveOptions
9+
from .live import LiveTranscriptionEvents
10+
from ..options import DeepgramClientOptions
11+
12+
# prerecorded
13+
from .prerecorded import PreRecordedClient
14+
from .prerecorded import AsyncPreRecordedClient
15+
from .prerecorded import PrerecordedOptions
16+
from .prerecorded import (
17+
PrerecordedSource,
18+
FileSource,
19+
UrlSource,
20+
BufferSource,
21+
ReadStreamSource,
22+
)
23+
from ..options import DeepgramClientOptions
24+
25+
# onprem
26+
from .onprem import OnPremClient
27+
from .onprem import AsyncOnPremClient
28+
from ..options import DeepgramClientOptions
29+
30+
# manage
31+
from .manage import ManageClient
32+
from .manage import AsyncManageClient
33+
from .manage import (
34+
ProjectOptions,
35+
KeyOptions,
36+
ScopeOptions,
37+
InviteOptions,
38+
UsageRequestOptions,
39+
UsageSummaryOptions,
40+
UsageFieldsOptions,
41+
)
42+
from ..options import DeepgramClientOptions

deepgram/clients/live/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright 2023 Deepgram SDK contributors. All Rights Reserved.
2+
# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
3+
# SPDX-License-Identifier: MIT
4+
5+
from .v1.client import LiveClient
6+
from .v1.async_client import AsyncLiveClient
7+
from .v1.options import LiveOptions
8+
from .enums import LiveTranscriptionEvents
9+
from ...options import DeepgramClientOptions
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright 2023 Deepgram SDK contributors. All Rights Reserved.
2+
# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
3+
# SPDX-License-Identifier: MIT
4+
5+
from .client import LiveClient
6+
from .async_client import AsyncLiveClient
7+
from .options import LiveOptions
8+
from ....options import DeepgramClientOptions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2023 Deepgram SDK contributors. All Rights Reserved.
2+
# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
3+
# SPDX-License-Identifier: MIT
4+
5+
from .v1.client import ManageClient
6+
from .v1.async_client import AsyncManageClient
7+
from .v1.options import (
8+
ProjectOptions,
9+
KeyOptions,
10+
ScopeOptions,
11+
InviteOptions,
12+
UsageRequestOptions,
13+
UsageSummaryOptions,
14+
UsageFieldsOptions,
15+
)
16+
from ...options import DeepgramClientOptions

0 commit comments

Comments
 (0)