GithubHelp home page GithubHelp logo

Comments (5)

mirceapasoi avatar mirceapasoi commented on July 19, 2024 1

@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.

dvonthenen avatar dvonthenen commented on July 19, 2024 1

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.

dvonthenen avatar dvonthenen commented on July 19, 2024

Taking a look at this.

from deepgram-python-sdk.

dvonthenen avatar dvonthenen commented on July 19, 2024

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.

dvonthenen avatar dvonthenen commented on July 19, 2024

@mirceapasoi I tested the above code with 3.1.6, it should work just fine.

from deepgram-python-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.