How to stream SoundCloud at a different speed or tempo? - soundcloud

From the SoundCloud API Guide, this is how to get the streaming URL of a sound:
import soundcloud
# create a client object with your app credentials
client = soundcloud.Client(client_id='YOUR_CLIENT_ID')
# fetch track to stream
track = client.get('/tracks/293')
# get the tracks streaming URL
stream_url = client.get(track.stream_url, allow_redirects=False)
# print the tracks stream URL
print stream_url.location
Is there any way to command the API to return a URL for the sound at a different speed or better yet, at a different tempo?

Thats not a feature from SoundClouds API. You need to somehow analyze your track to change the tempo / speed / bpm. For that you can use the EchoNest / Spotify APIs.
Check this question:
How to get BPM and tempo audio features in Python
If you change to JavaScript you can use the browser built-in WebAudio / WebMIDI API on Chrome and/or FireFox.
API description by Mozilla:
https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API
Examples by Google:
http://webaudiodemos.appspot.com/
Hackday project based on Samplr + SoundCloud API using WebAudio + WebMIDI (Chrome only):
http: // dope-dj-culture.com/ No longer a valid URL.

Related

Volumio - Play specific track via REST API

Using the REST API -https://volumio.github.io/docs/API/REST_API.html
Is there a method to play a specific track?
eg .
volumio.local/api/v1/commands/?cmd=playplaylist&name=Rock
But use a track name instead of a playlist.

Retriving data from facebook events

I have to create an webpage where i need to show all the events from the past or upcoming ones from an facebook page. I have to retrive the title, description, image, time and place of every single one and make a box with it.
After that, i have to retrive all the interested people.
I'm a beginner trying to make big things! Thank you very much.
This isnt a simple problem - I have just done this so will give you a start.
You need to use Facebooks Graph API to get the data, you will need to read up on the Graph API and how to use it. Documentation can be found here. Its worth noting due to a security breach the API isn't offering all of its services to new developers currently but you can get most - read about this here.
You can query the API using any language but I suggest do it with python and use the requests module. Alternatively you could use this SDK which makes things a lot easier, trust me! With the SDK you need to get a user access token which you can get from here.
SDK
With the SDK its possible to do this
import facebook
graph = facebook.GraphAPI(access_token="your_token", version="2.12")
event = graph.get_object(id='event_id',
fields='attending_count,declined_count')
print(event['attending_count'])
print(event['declined_count'])
You can add more fields to the fields list. However you can use any language you choose to request the data, as you can just construct your own URL's.
Graph API & Requests
This is how I did it in python using requests to query the API.
import requests, json
#Make a requests session to fetch data from URL's
session = requests.Session()
session.mount('https://', requests.adapters.HTTPAdapter(max_retries=10))
#API base URL
baseUrl = 'https://graph.facebook.com/v2.11/'
#Fields you want to get
fields = ['id', 'name', 'start_time', 'end_time', 'description', 'place']
#replace CLIENT_ID and CLIENT_SECRET with ones from a facebook app (make one)
tokenPath= 'oauth/access_token?client_id={0}&client_secret={1}&&'\
'grant_type=client_credentials'.format(CLIENT_ID, CLIENT_SECRET)
#Get the generated token
token = session.get(baseUrl + tokenPath).json()['access_token']
event = session.get(baseUrl, params={
"ids": "event_id",
"fields": ",".join(fields),
"access_token": token,
}
).json()
print(event["name"])
print(event["place"])
You can make a facebook app here which is where the CLIENT_ID & CLIENT_SECRET come from.
Why would you use URL requests and not the SDK?
Using the SDK the generated user access tokens expire every day, its possible to extend them but only for 60 days. If you want to use the SDK it has a method built in which allows you to extend the token, in order to extend the token you also need to create a facebook app. Its also possible to extend tokens using this website, though I cant vouch for its security - it could potentially access and exploit your data.
To extend the token with SDK:
import facebook
graph = facebook.GraphAPI(user_access_short_lived_token)
extended_token = graph.extend_access_token(app_id, app_secret)
print(extended_token)
Using the URL approach, you create a client access token at runtime (read about user access token vs client access token here) and the token is valid so long as your app is active. So if you are going to use this a lot or want to create it and not have to change/extend tokens then use the URL approach.
Hope this gets you started.

How do I play an audio file when using Fulfillment with Dialogflow

I'm making a Google Assistant action, similar to what Google does when you say "Play an E note".
I've managed to get my nodejs app to reply back the parameter, but now I need to pass an audio file. How do I do that?
The typical way to do this is to place the audio file on a hosting service somewhere (Firebase Hosting is a good choice, particularly if you're also using Firebase Cloud Functions for your Action, but any place that can serve a file via HTTPS works) and then send back SSML as your response that includes the audio.
This might look something like this:
var audioUrl = 'https://example.com/audiofile.mp3';
var msg = `<speak><audio src="${audioUrl}"></audio></speak>`
app.tell( msg );
Adjust this for your own audio file, and you might want to use app.ask() instead of tell if you are prompting the user to reply to your audio.

Picasa web albums - impossible to list all photos

I've uploaded about 40k photos using the Google Photos uploader tool, and now I'm trying to get a list of those photos using the Picasa Web Albums Data API (as there is no separate Google Photos API that I'm aware of).
So far, it appears impossible to get a complete list of all of the photos because you can list only 1000 photos at a time and then use the start-index parameter to do paging, but the server returns an error once you use a start-index above 11000. With a start-index of 11000 this occurs:
gdata.photos.service.GooglePhotosException: (500, 'Internal Server Error', 'Deprecated offset is too large for a stream ID query. Please switch to using resume tokens.')
(I'm using Python, but have confirmed that the error is independent of the language library)
I'd be happy to switch to using "resume tokens" like the error indicates... except that they are not mentioned in any documentation that I could find.
This is an authenticated request and the URL I'm using looks like this:
https://picasaweb.google.com/data/feed/api/user/[myUserID]/albumid/[myAlbumID]?kind=photo&max-results=1000&start-index=11000
Can anyone show me an example request using resume tokens or point me to documentation on them? Or, if anyone knows of some other way to get a complete list of all of the photos in a large album, that'd be great too. Thanks!
EDIT: the problem happens in any language, but in Python you can reproduce it consistently with:
startIndex = 1
while 1:
print '(fetching more photos)'
photos = client.GetFeed(ALBUM_URL, limit=1000, start_index=startIndex)
for photo in photos.entry:
print 'startIndex:', startIndex
startIndex += 1
where ALBUM_URL is like the URL I listed above and client is an authenticated instance of gdata.photos.service.PhotosService.

Is there any cookie system on samsung smart tv

I want to store my smarttv aplication's status. Example: I have a multipaged document and I want to store where the user left the program to open this page when the user reopens the program.
What is the efficient way to achieve this?
Given that you are talking about pages and cookies, I'll assume you are using the HTML / JavaScript API.
According to Samsung's list of JavaScript properties, the cookie property is supported. This is defined in the DOM Level 1 specification and Quirks Mode has a guide to using cookies from JavaScript.
You can use the official Samsung SDK to save a small quantity of data on the persistent memory of the device.
SDK: localData
This API allow you to save and read a value:
# saves current page state
sf.core.localData("currentPage", "home");
# reads current page state
var previousPage = sf.core.localData("currentPage");
Otherwise you can use the readFile API:
SDK: readFile