Giter Site home page Giter Site logo

Comments (1)

alexjbuck avatar alexjbuck commented on June 1, 2024

I have further narrowed this down.

If you write through an io.BytesIO object then it works.

# Writing to S3 through soundfile - Apparent Success
with smart_open.open(filepath.as_uri(), "wb", **transport_params) as file:
    with io.BytesIO() as temp:
        with sf.SoundFile(temp,mode='w', samplerate=sample_rate,channels=1,format='flac') as flac:
            flac.write(signal)
            print(f"S3 IO: {flac.frames=}")
        file.write(temp.getvalue())
# > S3 IO: f.frames=25000

# Reading without defining samples - Success
with smart_open.open(filepath.as_uri(), 'rb', **transport_params) as file:
    with sf.SoundFile(io.BytesIO(file.read())) as fin:
        print(f"S3 IO: {fin.frames=}")
        samples = fin.read()
        print(f"S3 IO: {len(samples)=}")
# > S3 IO: fin.frames=25000
# > S3 IO: len(samples)=25000

Compare this to the version that failed (which is the way I was led to believe this should work through the examples)

# Writing to S3 through soundfile - Apparent Success (actual failure!)
with smart_open.open(filepath.as_uri(), "wb", **transport_params) as file:
    with sf.SoundFile(file,mode='w', samplerate=sample_rate,channels=1,format='flac') as f:
        f.write(signal)
        print(f"S3 IO: {f.frames=}")
# > S3 IO: f.frames=25000

from smart_open.

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.