|
26 | 26 | print("Sound info specifying some request parameters:") |
27 | 27 | print("-----------") |
28 | 28 | sound = freesound_client.get_sound( |
29 | | - 96541, |
30 | | - fields="id,name,username,duration,analysis", |
31 | | - descriptors="lowlevel.spectral_centroid", |
32 | | - normalized=1 |
| 29 | + 96541, fields="id,name,username,duration,analysis", descriptors="lowlevel.spectral_centroid", normalized=1 |
33 | 30 | ) |
34 | 31 | print("Getting sound:", sound.name) |
35 | 32 | print("Username:", sound.username) |
|
52 | 49 | # Get sound analysis example specifying some request parameters |
53 | 50 | print("Get analysis with specific normalized descriptor:") |
54 | 51 | print("-------------") |
55 | | -analysis = sound.get_analysis( |
56 | | - descriptors="lowlevel.spectral_centroid.mean", |
57 | | - normalized=1 |
58 | | -) |
| 52 | +analysis = sound.get_analysis(descriptors="lowlevel.spectral_centroid.mean", normalized=1) |
59 | 53 | spectral_centroid_mean = analysis.lowlevel.spectral_centroid.mean |
60 | 54 | print("Normalized mean of spectral centroid:", spectral_centroid_mean) |
61 | 55 | print() |
|
72 | 66 | print("Similar sounds specifying some request parameters:") |
73 | 67 | print("---------------") |
74 | 68 | results_pager = sound.get_similar( |
75 | | - page_size=10, |
76 | | - fields="name,username", |
77 | | - descriptors_filter="lowlevel.pitch.mean:[110 TO 180]" |
| 69 | + page_size=10, fields="name,username", descriptors_filter="lowlevel.pitch.mean:[110 TO 180]" |
78 | 70 | ) |
79 | 71 | for similar_sound in results_pager: |
80 | 72 | print("\t-", similar_sound.name, "by", similar_sound.username) |
|
128 | 120 | print("\t-", sound.name, "by", sound.username) |
129 | 121 | print() |
130 | 122 |
|
131 | | - |
132 | 123 | # Getting sounds from a user example specifying some request parameters |
133 | 124 | print("User sounds specifying some request parameters:") |
134 | 125 | print("-----------") |
135 | 126 | user = freesound_client.get_user("Headphaze") |
136 | 127 | print("User name:", user.username) |
137 | 128 | results_pager = user.get_sounds( |
138 | | - page_size=10, |
139 | | - fields="name,username,samplerate,duration,analysis", |
140 | | - descriptors="rhythm.bpm" |
| 129 | + page_size=10, fields="name,username,samplerate,duration,analysis", descriptors="rhythm.bpm" |
141 | 130 | ) |
142 | 131 |
|
143 | 132 | print("Num results:", results_pager.count) |
144 | 133 | print("\t----- PAGE 1 -----") |
145 | 134 | for sound in results_pager: |
146 | | - print("\t-", sound.name, "by", sound.username,) |
147 | | - print(", with sample rate of", sound.samplerate, "Hz and duration of",) |
| 135 | + print( |
| 136 | + "\t-", |
| 137 | + sound.name, |
| 138 | + "by", |
| 139 | + sound.username, |
| 140 | + ) |
| 141 | + print( |
| 142 | + ", with sample rate of", |
| 143 | + sound.samplerate, |
| 144 | + "Hz and duration of", |
| 145 | + ) |
148 | 146 | print(sound.duration, "s") |
149 | 147 | print("\t----- PAGE 2 -----") |
150 | 148 | results_pager = results_pager.next_page() |
151 | 149 | for sound in results_pager: |
152 | | - print("\t-", sound.name, "by", sound.username,) |
153 | | - print(", with sample rate of", sound.samplerate, "Hz and duration of",) |
| 150 | + print( |
| 151 | + "\t-", |
| 152 | + sound.name, |
| 153 | + "by", |
| 154 | + sound.username, |
| 155 | + ) |
| 156 | + print( |
| 157 | + ", with sample rate of", |
| 158 | + sound.samplerate, |
| 159 | + "Hz and duration of", |
| 160 | + ) |
154 | 161 | print(sound.duration, "s") |
155 | 162 | print() |
156 | 163 |
|
|
160 | 167 | pack = freesound_client.get_pack(3524) |
161 | 168 | print("Pack name:", pack.name) |
162 | 169 | results_pager = pack.get_sounds( |
163 | | - page_size=5, |
164 | | - fields="id,name,username,duration,analysis", |
165 | | - descriptors="lowlevel.spectral_flatness_db" |
| 170 | + page_size=5, fields="id,name,username,duration,analysis", descriptors="lowlevel.spectral_flatness_db" |
166 | 171 | ) |
167 | 172 | print("Num results:", results_pager.count) |
168 | 173 | print("\t----- PAGE 1 -----") |
169 | 174 | for sound in results_pager: |
170 | | - print("\t-", sound.name, "by", sound.username, ", with duration of",) |
171 | | - print(sound.duration, "s and a mean spectral flatness of",) |
| 175 | + print( |
| 176 | + "\t-", |
| 177 | + sound.name, |
| 178 | + "by", |
| 179 | + sound.username, |
| 180 | + ", with duration of", |
| 181 | + ) |
| 182 | + print( |
| 183 | + sound.duration, |
| 184 | + "s and a mean spectral flatness of", |
| 185 | + ) |
172 | 186 | print(sound.analysis.lowlevel.spectral_flatness_db.mean) |
173 | 187 | print("\t----- PAGE 2 -----") |
174 | 188 | results_pager = results_pager.next_page() |
175 | 189 | for sound in results_pager: |
176 | | - print("\t-", sound.name, "by", sound.username, ", with duration of",) |
177 | | - print(sound.duration, "s and a mean spectral flatness of",) |
| 190 | + print( |
| 191 | + "\t-", |
| 192 | + sound.name, |
| 193 | + "by", |
| 194 | + sound.username, |
| 195 | + ", with duration of", |
| 196 | + ) |
| 197 | + print( |
| 198 | + sound.duration, |
| 199 | + "s and a mean spectral flatness of", |
| 200 | + ) |
178 | 201 | print(sound.analysis.lowlevel.spectral_flatness_db.mean) |
179 | 202 | print() |
180 | 203 |
|
|
187 | 210 | print("Num results:", results_pager.count) |
188 | 211 | print("\t----- PAGE 1 -----") |
189 | 212 | for bookmark_category in results_pager: |
190 | | - print("\t-", bookmark_category.name, "with", bookmark_category.num_sounds,) |
| 213 | + print( |
| 214 | + "\t-", |
| 215 | + bookmark_category.name, |
| 216 | + "with", |
| 217 | + bookmark_category.num_sounds, |
| 218 | + ) |
191 | 219 | print("sounds at", bookmark_category.url) |
192 | 220 | print() |
0 commit comments