GithubHelp home page GithubHelp logo

deepgram / deepgram-python-captions Goto Github PK

View Code? Open in Web Editor NEW
8.0 8.0 1.0 77 KB

This package is the Python implementation of Deepgram's WebVTT and SRT formatting. Given a transcription, this package can return a valid string to store as WebVTT or SRT caption files.

License: MIT License

Python 100.00%

deepgram-python-captions's People

Contributors

jpvajda avatar sandrarodgers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

nikitoshina

deepgram-python-captions's Issues

Converter does not accept a response unless it is a dictionary

What is the current behavior?

Now when getting a response from the Python SDK, the captions converter will not work. The response type that comes back from the SDK is a PrerecordedResponse type. This needs to be converted to a dictionary for the captions to work. This can be done by the user with this:

transcription = DeepgramConverter(json.loads(response.to_json()))

However, we need to fix the captions package to be able to handle that type and convert it to a dictionary.

Steps to reproduce

In the following code, change json.loads(response.to_json() to response or response.to_json() (remove the json.loads)

import json
from deepgram import (
    DeepgramClient,
    PrerecordedOptions,
)
from deepgram_captions import DeepgramConverter, srt

AUDIO_URL = {
    "url": "https://dpgr.am/spacewalk.wav"
}

deepgram = DeepgramClient("")
options = PrerecordedOptions(
    model="nova",
    smart_format=True,
    utterances=True
)
response = deepgram.listen.prerecorded.v("1").transcribe_url(AUDIO_URL, options)
if isinstance(json.loads(response.to_json()), dict):
    print("Response is a dictionary.")
else:
    print("Response is not a dictionary.")

transcription = DeepgramConverter(json.loads(response.to_json()))

captions = srt(transcription)
print(captions)

Expected behavior

Expect to not have to add json.loads

OR MAYBE JUST UPDATE THE README TO INFORM USERS OF HOW TO DO THIS

See discord conversation where this was originally raised: https://discord.com/channels/1108042150941294664/1204723190044295238/1204723190044295238

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.