User:Angeliki/Grad-prototyping

From Media Design: Networked & Lens-Based wiki
Jump to navigation Jump to search

GUIDES

Antennas making: https://sat.weblog.mur.at/

Radio: https://anarchy.translocal.jp/radio/micro/howtosimplestTX.html

Radio to speech: https://towardsdatascience.com/make-amateur-radio-cool-again-said-mr-artificial-intelligence-36cb32978fb2

Speech tools: http://www.speech.cs.cmu.edu/, https://realpython.com/python-speech-recognition/, https://cmusphinx.github.io/, https://github.com/Uberi/speech_recognition, https://sourceforge.net/projects/cmusphinx/files/Acoustic%20and%20Language%20Models/, http://www.lingoes.net/en/translator/langcode.htm


Dipole_xmting_antenna_animation_4_408x318x150ms.gif

Zine-machines

coordinates to lines

zine-machines.kstraat.casa

export GPS data, publish routes/video frames to raw data-publish

thump thump

 1 import pykml
 2 from pykml import parser
 3 import csv
 4 import re
 5 from reportlab.lib.pagesizes import letter
 6 from reportlab.pdfgen import canvas
 7 
 8 
 9 def translate(value, leftMin, leftMax, rightMin, rightMax):
10     # Figure out how 'wide' each range is
11     leftSpan = leftMax - leftMin
12     rightSpan = rightMax - rightMin
13 
14     # Convert the left range into a 0-1 range (float)
15     valueScaled = float(value - leftMin) / float(leftSpan)
16 
17     # Convert the 0-1 range into a value in the right range.
18     return rightMin + (valueScaled * rightSpan)
19 
20 
21 kml_file='prlll.kml'
22 all_routes = {} 
23 with open(kml_file) as f:
24     doc = parser.parse(f).getroot().Document.Folder
25 
26 for pm in doc.iterchildren():
27     if hasattr(pm, 'LineString'):
28         name = pm.name.text
29         coordinates = pm.LineString.coordinates.text
30         cordinatesinline =  coordinates.split('\n')
31         cordinatesasarray = []
32         for line in cordinatesinline:
33         	pattern = re.compile("^\s+|\s*,\s*|\s+$")
34         	array = [x for x in pattern.split(line) if x]
35         	if array:
36         		cordinatesasarray.append(array)
37         all_routes[name]= cordinatesasarray
38 
39 
40 
41 canvas=canvas.Canvas("route.pdf", pagesize=letter)
42 canvas.setLineWidth(.8)
43 canvas.setFont('Helvetica', 6)
44 for name in all_routes:
45 	x=[]
46 	y=[]
47 	for points in all_routes[name]:
48 		x.append(points[0])
49 		y.append(points[1])
50 
51 	i=0
52 	for a in x:
53 		if i < len(x)-1:
54 			x_new=translate(float(x[i]),float(min(x)), float(max(x)),50,500)
55 			y_new=translate(float(y[i]),float(min(y)),float(max(y)),50,500)
56 			x_new2=translate(float(x[i+1]),float(min(x)), float(max(x)),50,500)
57 			y_new2=translate(float(y[i+1]),float(min(y)),float(max(y)),50,500)
58 			print x_new,y_new,x_new2,y_new2
59 			canvas.line(x_new,y_new,x_new2,y_new2)
60 			i=i+1
61 	canvas.drawString(10,45,name)
62 	canvas.showPage()
63 canvas.save()

Mastodon-bot

A way to publish some text or images to Mastodon (a decentralized, open source social network) using a bot account.

Walking/annotating/listening/transcribing/present voice

Walking the text

walking_the_text Radio speech-coordinates lines.JPG

Los Banos(PH) voices/ Nomidu Nuna Exhibition

37844413 452939751875169 180676655528804352 n.jpg


The secrets of pocketsphinx

Acoustic model/training

0 46797 She had your dark suit in greasy wash water all year.

File:

1	Η	ο	At	AtDf	Fe|Sg|Nm	2	Atr	_	_
2	Σίφνος	Σίφνος	No	NoPr	Fe|Sg|Nm	3	Sb	_	_
3	φημίζεται	φημίζομαι	Vb	VbMn	Id|Pr|03|Sg|Xx|Ip|Pv|Xx	0	Pred	_	_
4	και	και	Cj	CjCo	_	5	AuxY	_	_
5	για	για	AsPp	AsPpSp	_	3	AuxP	_	_
6	τα	ο	At	AtDf	Ne|Pl|Ac	8	Atr	_	_
7	καταγάλανα	καταγάλανος	Aj	Aj	Ba|Ne|Pl|Ac	8	Atr	_	_
8	νερά	νερό	No	NoCm	Ne|Pl|Ac	5	Obj	_	_
9	των	ο	At	AtDf	Fe|Pl|Ge	11	Atr	_	_
10	πανέμορφων	πανέμορφος	Aj	Aj	Ba|Fe|Pl|Ge	11	Atr	_	_
11	ακτών	ακτή	No	NoCm	Fe|Pl|Ge	8	Atr	_	_
12	της	μου	Pn	PnPo	Fe|03|Sg|Ge|Xx	11	Atr	_	_
13	.	.	PUNCT	PUNCT	_	0	AuxK	_	_

1	Πιστεύω	πιστεύω	Vb	VbMn	Id|Pr|01|Sg|Xx|Ip|Av|Xx	0	Pred	_	_
2	ότι	ότι	Cj	CjSb	_	1	AuxC	_	_
3	είναι	είμαι	Vb	VbMn	Id|Pr|03|Sg|Xx|Ip|Pv|Xx	2	Obj	_	_
4	δίκαιο	δίκαιο	No	NoCm	Ne|Sg|Nm	3	Pnom	_	_
5	να	να	Pt	PtSj	_	7	AuxV	_	_
6	το	εγώ	Pn	PnPe	Ne|03|Sg|Ac|We	7	Obj	_	_
7	αναγνωρίσουμε	αναγνωρίζω	Vb	VbMn	Id|Xx|01|Pl|Xx|Pe|Av|Xx	3	Sb	_	_
8	αυτό	αυτός	Pn	PnDm	Ne|03|Sg|Ac|Xx	7	Obj	_	_
9	.	.	PUNCT	PUNCT	_	0	AuxK	_	_

1	Η	ο	At	AtDf	Fe|Sg|Nm	2	Atr	_	_

Radio2text

FM2text

I want to use speech_recognition to transcribe speech from radio (FM, AM, FSK,...)
I made a test prototyping and here are the instructions

Fmtoradio test.jpg

python listen.py --freq=93400000
  1 from typing import List
  2 from rtlsdr import RtlSdr
  3 import argparse
  4 import datetime
  5 import numpy as np
  6 import pyaudio
  7 import scipy.signal as signal
  8 import speech_recognition as sr
  9 import threading
 10 
 11 SampleStream = List[float]
 12 AudioStream = List[int]
 13 
 14 stream_buf = bytes()
 15 stream_counter = 0
 16 
 17 audio_rate = 48000
 18 
 19 recognizer = sr.Recognizer()
 20 audio_output = pyaudio.PyAudio().open(format=pyaudio.paInt16, channels=1, rate=audio_rate, output=True)
 21 
 22 
 23 def recognize(stream_text):
 24     global args
 25 
 26     def logger(s):
 27         f = open('radio_log.txt', 'a+', encoding='utf-8')
 28         f.write(datetime.datetime.now().strftime("[ %d-%b-%Y %H:%M:%S ] "))
 29         f.write(s)
 30         f.write("\x0A")
 31         f.close()
 32 
 33     # print('sync')
 34     audio_data = sr.AudioData(stream_text, audio_rate, 2)
 35     try:
 36         # result = recognizer.recognize_sphinx(audio_data)
 37         result = recognizer.recognize_google(audio_data, language=args.lang)
 38         print(result)
 39         logger(result)
 40     except sr.UnknownValueError:
 41         pass
 42     except sr.RequestError as e:
 43         print("Could not request results from GSR service; {0}".format(e))
 44     # print('done')
 45 
 46 
 47 def stream_audio(data: AudioStream):
 48     global args
 49     global stream_buf
 50     global stream_counter
 51 
 52     if not args.verbose:
 53         audio_output.write(data)
 54 
 55     if stream_counter < args.buf:
 56         stream_buf += data
 57         stream_counter += 1
 58     else:
 59         threading.Thread(target=recognize, args=(stream_buf,)).start()
 60         stream_buf = bytes()
 61         stream_counter = 0
 62 
 63 
 64 def process(samples: SampleStream, sdr: RtlSdr) -> None:
 65     sample_rate_fm = 240000
 66     iq_comercial = signal.decimate(samples, int(sdr.get_sample_rate()) // sample_rate_fm)
 67 
 68     angle_comercial = np.unwrap(np.angle(iq_comercial))
 69     demodulated_comercial = np.diff(angle_comercial)
 70 
 71     audio_signal = signal.decimate(demodulated_comercial, sample_rate_fm // audio_rate, zero_phase=True)
 72     audio_signal = np.int16(14000 * audio_signal)
 73 
 74     stream_audio(audio_signal.astype("int16").tobytes())
 75 
 76 
 77 def read_callback(samples, rtl_sdr_obj):
 78     process(samples, rtl_sdr_obj)
 79 
 80 
 81 parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
 82 parser.add_argument('--ppm', type=int, default=0,
 83                     help='ppm error correction')
 84 parser.add_argument('--gain', type=int, default=20,
 85                     help='RF gain level')
 86 parser.add_argument('--freq', type=int, default=92900000,
 87                     help='frequency to listen to, in Hertz')
 88 parser.add_argument('--lang', type=str, default='en-US',
 89                     help='language to recognize, en-US, ru-RU, fi-FI or any other supported')
 90 parser.add_argument('--buf', type=int, default=100,
 91                     help='buffer size to recognize, 100 = 6.25 seconds')
 92 parser.add_argument('--verbose', action='store_true',
 93                     help='mute audio output')
 94 
 95 args = parser.parse_args()
 96 
 97 sdr = RtlSdr()
 98 sdr.rs = 2400000
 99 sdr.fc = args.freq
100 sdr.gain = args.gain
101 sdr.err_ppm = args.ppm
102 
103 sdr.read_samples_async(read_callback, int(sdr.get_sample_rate()) // 16)

FM2text/ Django

This prototyping is about live streaming the output of the speech recognition of radio speech into a web platform. I embedded the listen.py from the previous experiment to a django infrastructure. The output of the script, which is a logfile, is being shown and updated in a url of my instance in django.

[ 29-Oct-2018 19:07:34 ] super
[ 29-Oct-2018 19:07:40 ] YouTube
[ 29-Oct-2018 19:08:54 ] learning Justin Bieber songs on ukulele
[ 29-Oct-2018 19:09:00 ] baby shark
[ 29-Oct-2018 19:09:05 ] thinking she would be a perfect day to register
[ 29-Oct-2018 19:09:13 ] I found out sooner I think you left it off and told me another
[ 29-Oct-2018 19:09:18 ] racing at a time there I'm reading trophy with a salad on a
[ 29-Oct-2018 19:09:22 ] bring you flowers Julian to £10 a week
[ 29-Oct-2018 19:09:30 ] Man Utd Man City Derby
[ 29-Oct-2018 19:09:35 ] Andrew Page AZ baby
[ 29-Oct-2018 19:09:41 ] The Breaking of the time
[ 29-Oct-2018 19:09:44 ] me on a line and a dozen Roses say I am finally
[ 29-Oct-2018 19:09:50 ] a road song about you didn't care about the chair
[ 29-Oct-2018 19:09:55 ] all I wanted was for you to keep it in your house bring you down
[ 29-Oct-2018 19:10:02 ] do you do Stefan and Daily Mail
[ 29-Oct-2018 19:10:07 ] Lowdham caravans
[ 29-Oct-2018 19:10:12 ] compromise
[ 29-Oct-2018 19:10:18 ] young drivers to your doorstep undertale
[ 29-Oct-2018 19:10:23 ] plane crazy Argos
[ 29-Oct-2018 19:10:31 ] are you ok baby
[ 29-Oct-2018 19:10:35 ] sorry


 1 //index.html
 2 <!DOCTYPE html>
 3 <html lang="en" dir="ltr">
 4   <head>
 5     <meta charset="utf-8">
 6     <title></title>
 7     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
 8   </head>
 9   <body>
10     <p id='text'></p>
11 <script>
12 function sendRequest(){
13 $.ajax({
14         url: "http://localhost:8000/radio_speech/draft",
15         method: "GET",
16         success:
17         function(result){
18             // console.log('ss'); //check if it is working in the console
19             $('#text').text(result); //insert text of test.php into your div
20             setTimeout(function(){
21                 sendRequest(); //this will send request again and again;
22             }, 5000);
23         }
24     });
25     }
26     sendRequest();
27 </script>
28   </body>
29 </html>

NEXT:

  • scanning through several frequencies and speech recognition
  • the software listens to different inputs and transcribes every time it listens to a specific word related to a topic (surveillance in the opposite). The inputs come from different places. Of people walking and talking, radio, pirates, youtube? "walk book?"

Pirates speech to text

[1]

Collect radio sounds

An attempt to collect radio sounds depending on what text accompanies them, on time, on frequencies or other factors. For example every time the software listens to streaming and recognizes a sound of voice (300 and 3000 Hz) or a word then it records down/collects.

Antennas

Directing to satellites


Web Radio

Net Art radio


Trained data/ speech recognition

samples:


I wish I had your strength.

tatoeba.org for Common Voice of Mozilla

LDC93S1 0 46797 She had your dark suit in greasy wash water all year.

catalog.ldc.upenn.edu for Pocketsphinx

por que al fin y al cabo el miedo de la mujer a la violencia del hombre es el espejo del miedo del hombre a la mujer sin miedo CMPB_M_32_01IVN_00004

catalog.ldc.upenn.edu for Pocketsphinx (broadcast conversation)

Interview 15
(A=Interviewer; B=Interviewee)
A: So we are recording.  Awesome.  So how long have you lived in Flint? (unclear)
B: 38 years.
A: Is that your whole life?  Wow you look really young.
B: Thank you!
A: So what can you tell me about what it’s like to have grown up around here?
B: Normal, just very- Working class, nice people.  Good values, good heart.  Did all the usual.  Rode my bike.  Played outside.  Brownies. Family-oriented.  Just very- I mean- very Midwestern.  You know.  Cliché. I mean really.
A: Okay.  Have you- have you traveled around to other places to see how things are like in comparison to Flint?
B: Um…do you mean throughout the county or the state or the country or-
A: Any. (unclear)
B: Any…um… unfortunately I haven’t been able to travel that much.  My traveling has been just basically through the state.  A couple trips to Canada.  Ontario.  Some through the- like- I guess you’d say upper Midwest.  Ohio.  Illinois.  Indiana.  Iowa. And it’s- I find it very similar.  I mean different.  I mean.  What their economy was based in.  Because it wasn’t GM.  They were really sim- It was- felt like really similar.  Just the way people are- small communities are nice and down to earth.  What I come across but just similar.  But I would like to travel more in my life.  
A: So would you say, like it- you kind of had like a typical American experience growing up in Flint?
B: Yeah, I would say so, just um … like I said, bike riding, Brownies. I was fortunate I had both my parents stay together.  Most of my friends got divorced, their parents got divorced, so we were atypical in that sense. And just...um, normal neighborhood, just close but not in each other’s business, so to speak, and just family oriented. Nothing too exciting. 
catalog.ldc.upenn.edu for Pocketsphinx (microphone conversation)


Streaming

9280f2.inline.jpg

Install icecast and ices: http://pzwiki.wdka.nl/mediadesign/Icecast#Ices

Examples: https://adm.amsterdam/radio/playertest/index.html

Icecast-streaming-sample


Very interesting diagram and project for a hybrid radio (http://p-node.org/doc/index.php/V-2_-_definitive_step_by_step_installation_guide)

DiagramA-PiBox.png

Opening PORTS

Differences of TCP and UDP

streaming audio files/packages streaming live
TCP UDP
https://www.maketecheasier.com/run-a-diy-internet-radio-station-with-icecast-linux/ https://stackoverflow.com/questions/40068906/how-to-capture-html5-microphone-input-to-icecast/40073233#40073233
playlist soundcard
storage live/presence
permanent temporary
Netflix Skype, https://en.wikipedia.org/wiki/Voice_over_IP
Part of the flow Part of the flow

Feedback Composition