Skip to content

[Docs]: AttributeError: 'generator' object has no attribute 'stream' in readme snippet #638

@Vanny-Chuck

Description

@Vanny-Chuck

Affected page or section

readme.md

What is unclear or wrong?

AttributeError: 'generator' object has no attribute 'stream'  in

from deepgram import DeepgramClient

client = DeepgramClient(api_key = "my key")

response = client.speak.v1.audio.generate(
    text="Hello, this is a sample text to speech conversion."
)

# Save the audio file
with open("output.mp3", "wb") as audio_file:
    audio_file.write(response.stream.getvalue())
                              ^^^^^^

Suggested change

from deepgram import DeepgramClient

client = DeepgramClient(api_key = "secret stuff")

response = client.speak.v1.audio.generate(
    text="Hello, this is a sample text to speech conversion."
)

# Save the audio file
with open("output.mp3", "wb") as audio_file:
    for a in response:
        audio_file.write(a)

Example code (if any)

SDK parity (if relevant)

  • This change may need updates in other SDKs

Session ID (optional)

No response

Project ID (optional)

No response

Request ID (optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions