This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
""" | |
Turn a long text into a sound file, using Coqui TTS: text-to-speech | |
Example usage: | |
./doc_2_audio.py -e utf16 my_dir/my_document.txt | |
Will produce output my_dir/my_document.wav |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Optional To find out what processes are using GPU | |
sudo fuser -v /dev/nvidia* | |
# to restart | |
sudo rmmod nvidia_uvm && sudo modprobe nvidia_uvm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# remove unsused packages | |
sudo apt-get autoremove | |
# clean APT cache | |
sudo apt-get clean | |
# clean oldish journal logs | |
sudo journalctl --vacuum-time=1d | |
# remove old versions of snap packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Array where Element == Double { | |
func mean() -> Double { | |
if self.count == 0 { return Double.nan } | |
var ret = 0.0 | |
for x in ret { | |
ret += x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct InfRepeater: Sequence { | |
// a sequence that loops infinitely over another sequence | |
typealias Iterator = InfRepeaterIter | |
typealias Element = Int | |
var arr: Array<Element> | |
func makeIterator() -> Iterator { | |
return InfRepeaterIter( i: 0, arr: arr ) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Sequence { | |
func take(_ n: Int ) -> [Self.Element] { | |
// yield the first n elements of a sequence as an array | |
var ret = [Self.Element]() | |
for ( _, e) in zip( 0..<n, self ) { | |
ret.append(e) | |
} | |
return ret | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Inferred types from first 100 line(s) of file as | |
column_type_hints=[int,str,float,float,int] | |
------------------------------------------------------ | |
Read 870755 lines. Lines per second: 520097 | |
Finished parsing file /home/ubuntu/dask_experiment/Gowalla_totalCheckins.txt | |
Parsing completed. Parsed 6442892 lines in 5.43026 secs. | |
+---------+-----------+----------------+ | |
| stalkee | stalker | location_count | | |
+---------+-----------+----------------+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final_result = ( pairs_filtered[['stalkee', 'stalker', 'location_id']] | |
.unique() | |
.groupby( ['stalkee','stalker'] , | |
{"location_count" : agg.COUNT }) | |
.topk( 'location_count', k=5 ) | |
.materialize() ) | |
print( final_result ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chin_ps = ( checkins.join( checkins, on = 'location_id' ) | |
.rename( {'checkin_ts' : 'checkin_ts_ee', | |
'checkin_ts.1' : 'checkin_ts_er', | |
'user_id' : 'stalkee' , | |
'user_id.1' : 'stalker' } ) ) | |
pairs_filtered = chin_ps[ (chin_ps['checkin_ts_ee'] < chin_ps['checkin_ts_er']) & | |
(chin_ps['stalkee'] != chin_ps['stalker]) ] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import turicreate as tc | |
checkins = ( tc.SFrame.read_csv( 'Gowalla_totalCheckins.txt', | |
delimiter='\t', header=False ) | |
.rename( {'X1': 'user_id', 'X2' : 'checkin_ts', | |
'X3': 'lat', 'X4' : 'lon', | |
'X5': 'location_id'} ) | |
[["user_id", "location_id", "checkin_ts"]] ) |
NewerOlder