Comments (5)
@dvonthenen I am using transcribe_file
, which seems to crash around here, due to the "key" in provided_source
check calling __getitem__
:
if is_buffer_source(source):
body = source["buffer"]
elif is_readstream_source(source):
body = source["stream"]
...
def is_buffer_source(provided_source: PrerecordedSource) -> bool:
return "buffer" in provided_source
def is_readstream_source(provided_source: PrerecordedSource) -> bool:
return "stream" in provided_source
from deepgram-python-sdk.
I reverted it.... GitHub is dying this morning. Waiting for the outage-ish to end so I can post a new release. Closing since the update has been merged.
from deepgram-python-sdk.
Taking a look at this.
from deepgram-python-sdk.
The @dataclass
was an experiment that I forgot about and unintentionally commited, but the older input should still work just like before.
This should still work:
# Copyright 2023 Deepgram SDK contributors. All Rights Reserved.
# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
# SPDX-License-Identifier: MIT
import os
from dotenv import load_dotenv
import logging, verboselogs
from datetime import datetime, timedelta
from io import BufferedReader
from deepgram import DeepgramClientOptions
import logging
from deepgram import (
DeepgramClient,
DeepgramClientOptions,
StreamSource,
AnalyzeOptions,
TextSource,
)
load_dotenv()
TEXT_FILE = "conversation.txt"
def main():
try:
# STEP 1 Create a Deepgram client using the API key in the environment variables
config = DeepgramClientOptions(
verbose=logging.SPAM,
)
deepgram = DeepgramClient("", config)
# OR use defaults
# deepgram = DeepgramClient()
# STEP 2 Call the transcribe_file method on the prerecorded class
stream = open(TEXT_FILE, "rb")
payload: StreamSource = {
"stream": stream,
}
options = AnalyzeOptions(
language="en",
intents=True,
)
response = deepgram.read.analyze.v("1").analyze_text(payload, options)
print(response.to_json(indent=4))
except Exception as e:
print(f"Exception: {e}")
if __name__ == "__main__":
main()
If the dataclass thing doesn't panout, I will revert the name back to ReadStreamSource
and convert back to the TypedDict
. Will have this done tomorrow.
from deepgram-python-sdk.
@mirceapasoi I tested the above code with 3.1.6, it should work just fine.
from deepgram-python-sdk.
Related Issues (20)
- Deepgram audio timeout window error HOT 20
- Implement TTS HOT 2
- Fix PyDocs to Only Generate on GA `vX.Y.Z` HOT 1
- Error: keepalive ping timeout; no close frame received HOT 6
- Pyright type definitions check fails with upgrade to 3.1.5 HOT 3
- Misc Typing Bug HOT 1
- Fatal error on SSL transport HOT 3
- Include `encoding` and `sampling_rate` in Prerecorded API HOT 1
- Clarify Support for Examples on Windows HOT 3
- Improved Websocket support for Latency HOT 1
- Improve retries for failed Requests HOT 1
- Improved chunking of TTS HOT 1
- Keepalive thread throws errors even when the "keepalive" option is not set HOT 5
- Custom Headers per REST and WS Call HOT 1
- Implement `UnhandledEvent()` like in Go SDK HOT 1
- Implement Flush Feature
- Unhandled exceptions in AsyncLiveClient._listening HOT 1
- Allow `wss://` in the onprem URL. HOT 8
- Issues running Deepgram with fastapi sockets HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deepgram-python-sdk.