You are not logged in.

#1 2021-05-24 07:54:02

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,436
Website

Text to valid json?

So I have been playing with some txt2speech generators, one of them being cloudy IBM Watson, so far I got the 'correct' curl call, which seems to be

curl -X POST -u "apikey:{yourapikey}" --header "Content-Type: application/json" --header "Accept: audio/ogg;codecs=opus" --data-binary "@test.txt" --output test4.opus "https://{url}/v1/synthesize?voice=en-US_AllisonVoice"

where test.txt is json type of thing

{
"text":"They had now reached the airlock - a large circular steel hatchway of massive strength and weight"
}

What would be a tool to automagically construct such json (valid) constructs from various text inputs, including text that has various quotes and stuff? (correctly escaped i guess)

Last edited by brontosaurusrex (2021-05-24 08:08:23)

Offline

#2 2021-05-24 08:36:18

twoion
一期一会
Registered: 2015-08-10
Posts: 3,437

Re: Text to valid json?

#!/usr/bin/env bash
jq -c -n --arg input 'This is arbitrary text input' '{ text: $input }'
jq -c -n --arg input "$(<anything.txt)" '{ text: $input }'

Offline

#3 2021-05-24 09:31:10

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,436
Website

Re: Text to valid json?

^Thanks. edit: Got it working and actually reading the entire book (The Hitch Hiker's Guide to the Galaxy ).

Last edited by brontosaurusrex (2021-05-24 20:34:33)

Offline

#4 2021-05-25 03:30:48

hhh
Ol' Pink Eyes
Registered: 2015-09-17
Posts: 12,776
Website

Re: Text to valid json?

Hope you brought your towel!


Does your physical disability preclude you from coming to the point?

Offline

#5 2021-05-25 05:40:33

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,436
Website

Re: Text to valid json?

^It is kinda interesting how 'wrong' the entire thing sounds and I don't mean just sentence by sentence, where pretty much every ' , ' and ' . ' are read as in 1st grade, but also the lack of any weight bias as to what are the boring parts (which human would read faster or skip). Also the emotional interpretation seems to be localized to parts of the sentences and extremely rarely done right (seems like pure luck). Also all very interesting at the same time.
https://youtu.be/445fLyJd6hY

Last edited by brontosaurusrex (2021-05-26 05:45:09)

Offline

Board footer

Powered by FluxBB