Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ pip install ici

### 使用方法:

$ ici what

$ ici [-p] what
argument:
-p  查词的同时播放读音(需要mpg123);

[wɒt]

[wɑ:t]
Expand Down
12 changes: 11 additions & 1 deletion ici/ici.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys
import getopt
import logging
import subprocess
from xml.dom import minidom
from collections import namedtuple
try:
Expand Down Expand Up @@ -59,9 +60,15 @@ def show(node):
show(e)


def pronounce(node):
elements = node.getElementsByTagName("pron")
pron_urls = [a.firstChild.data for a in elements]
subprocess.Popen("mpg123 -q " + " ".join(pron_urls), shell=True)


def main():
try:
options, args = getopt.getopt(sys.argv[1:], ["help"])
options, args = getopt.getopt(sys.argv[1:], "p", ["help"])
except getopt.GetoptError as e:
pass

Expand All @@ -72,6 +79,9 @@ def main():
return
root = read_xml(response)
show(root)
for option in options:
if '-p' in option:
pronounce(root)


if __name__ == '__main__':
Expand Down