mastodontech.de ist einer von vielen unabhängigen Mastodon-Servern, mit dem du dich im Fediverse beteiligen kannst.
Offen für alle (über 16) und bereitgestellt von Markus'Blog

Serverstatistik:

1,4 Tsd.
aktive Profile

#async

2 Beiträge2 Beteiligte0 Beiträge heute

I could use some help with #Python #async -

I'm building a #LanguageLearning tool where you can convert a list of phrases into individual voice audio files.

I'm using #FastAPI to run an API which accepts a list of phrases from an HTML form, and uses ElevenLabs #TextToSpeech to make audio files, bundle them into a Zip file for the browser to download.

The problem is sequential API calls are slow - would love to request them ASync.

Suggestions?

Code:

codeberg.org/jro/Typhoon_phras

Zusammenfassungskarte des Repositorys jro/Typhoon_phrases-to-voice-audio
Codeberg.orgTyphoon_phrases-to-voice-audio/app/services/text_speech_api.py an 5719e070d734604eff7f0d9b97e0dd57c30431bdTyphoon_phrases-to-voice-audio - Converts list of phrases into individual audio files.
Antwortete im Thread

Ok, @calisti, I _think_, I've figured it out now (please read until the later parts of the toots as they are the most important)!🤓

Tldr; The `or` or `race` operators _on their own_ are not suitable for cancelling streams! One needs a `StopToken` or enum value _within the stream_ that signals cancellation/allows for short-circuiting.

1/?

#Rust#RustLang#AsyncRust

async-primitives reached 1.0.0

If you are interested in performing additional calculations on Promise<T>, you may find this small library useful. Mutex, producer-consumer separation (side-effect operation), signaling (flag control), logical context and more.

* Works in both browser and Node.js environments (16 or later, tested only 22).
* No external dependencies.

#typescript #promise #async

github.com/kekyo/async-primiti

A collection of primitive functions for asynchronous operations in TypeScript/JavaScript. - kekyo/async-primitives
GitHubGitHub - kekyo/async-primitives: A collection of primitive functions for asynchronous operations in TypeScript/JavaScript.A collection of primitive functions for asynchronous operations in TypeScript/JavaScript. - kekyo/async-primitives
Fortgeführter Thread

For anyone willing to peer into the abyss ... github.com/DrHyde/shellscripts

Instead of running three other scripts (each of which is a wrapper around `ffmpeg`) in turn, it now runs them in parallel, capturing the results, and then spitting out the results consistently no matter in what order the individual scripts finished.

I think in #Javascript this would be called #async / #await or some such. Normal devs just call it "programming".

GitHubffinfo: make it more fasterer; also a little shellcheck placation · DrHyde/shellscripts@7aa1c37Random shell stuff. Contribute to DrHyde/shellscripts development by creating an account on GitHub.

Async #Rust is actually awesome! :awesome:

The last few days I've built a prototype(!) of a global "Hotkey" system e.g.:

Press & Hold `LCtrl + Space`
=> an async stream starts and only finishes if:
- another key is pressed or
- one of the Hotkeys is released

If it is not clear by now: this is a state-machine, which fits _perfectly_ into Rust's #async model!

And the best part: This is actually _the first time_ I've ever touched async #RustLang! Such a pleasant experience!

1/?

So I have been looking for a #Rust crate that can provide _global hot key support_ without a window in focus.

First tried `rdev`, but it doesn't support unsubscribing from events. 😩

docs.rs/rdev/latest/rdev/

However, I've learned a ton about:
- bridging sync/async
- async cancellation
- custom `Drop` impl with pin_project crate:
=> docs.rs/pin-project/latest/pin

I'll now look into `device_query` crate (supports unsubscribing via dropping the guard):
docs.rs/device_query/latest/de

docs.rsrdev - RustSimple library to listen and send events to keyboard and mouse on MacOS, Windows and Linux (x11).