Difference between revisions of "User:Ypolius"

From eLinux.org
Jump to: navigation, search
m (Moved to ECE597Spring2010)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
[[Category:ECE597]]
+
[[Category:ECE597Spring2010 |U]]
I am a senior Computer Science student who has elected to take this course in order to get more familiar with linux on the kernel side. I am very comfortable with the linux environment and would love to learn how it works. Currently I am working on the audio mbox project.
 
  
----
+
I am a senior Computer Science student who has elected to take this course in order to get more familiar with linux on the kernel side. I am very comfortable with the linux environment and would love to learn how it works. Currently I am working on the pyWikiReader project.
'''Project Work'''
 
3/30/2010
 
So far I have gotten a python script that runs on the beagleboard. This script takes in a textual topic and speaks the intro of the topic's wiki page using flite. The script is:
 
 
 
----
 
 
 
    # -*- coding: utf-8 -*-
 
    import commands
 
    import HTMLParser
 
    import re
 
    class CustomParser(HTMLParser.HTMLParser):
 
        def __init__(self, *args, **kwargs):
 
            HTMLParser.HTMLParser.__init__(self)
 
            self.stack = []
 
        def handle_starttag(self,  tag,  attrs):
 
            if tag.lower() == 'p':
 
                self.stack.append(tag)
 
        def handle_endtag(self,  tag):
 
            if tag.lower() == 'p':
 
                self.stack.append(tag) 
 
        def handle_data(self,  data):
 
            if len(self.stack) > 0:
 
                self.stack.append(data)
 
    topic = raw_input('Enter a wikipedia topic you would like to hear about\n').replace(' ',  '+')
 
    commands.getstatusoutput('wget --output-document=result.html http://en.wikipedia.org/wiki/Special:Search?search=' + topic +'&go=Go')
 
    parser = CustomParser()
 
    html = open('result.html',  'r')
 
    parser.feed(html.read())
 
    html.close()
 
    parser.close()
 
    info_string =""
 
    for string in parser.stack:
 
        if string == 'p':
 
            pass
 
        else:
 
            info_string += string
 
    info_string = info_string.split('\n')
 
    paragraphs = filter(lambda x: len(x) > 150,  info_string)
 
    intro =  paragraphs[0]
 
    citation_free= re.sub('\[[0-9]\]', '',  intro)
 
    output = open('output.txt',  'w')
 
    output.write(citation_free)
 
    output.close()
 
    commands.getstatusoutput('flite output.txt speech.wav')
 
    commands.getstatusoutput('mplayer speech.wav')</nowiki>
 
  
 
----
 
----
The python package can be installed with the 'opkg install python' command. Since this script depends on HTMLParser and the python installation is minimal, you need to get some dependencies. They are HTMLParser.py, markupbase.py, and htmlenvprefs.py (unsure of name, something similar) and can be obtained from a more fleshed out install. I copied my files over using scp from an Arch Linux python installation and it worked fine.
 

Latest revision as of 17:11, 21 July 2014


I am a senior Computer Science student who has elected to take this course in order to get more familiar with linux on the kernel side. I am very comfortable with the linux environment and would love to learn how it works. Currently I am working on the pyWikiReader project.