Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
Binary file added xyjxyf/0000/0000.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions xyjxyf/0004/0004.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

Henry was a pen name used by an American writer of short stories.

His real name was William Sydney Porter.
Binary file added xyjxyf/0005/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xyjxyf/0005/2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions xyjxyf/0006/00061.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

Henry was a pen name used by an American writer of short stories.

His

His

His

His

Henry was a pen name used by an American writer of short stories.
7 changes: 7 additions & 0 deletions xyjxyf/0006/00062.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

Henry was a pen name used by an American writer of short stories.

His real name was William Sydney Porter.

pen pen
pen pen pen pen pen pen
29 changes: 29 additions & 0 deletions xyjxyf/0007/stringer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# coding = utf-8

import random, string

/*
sdfhjdsf
hgjh
*/
# def Unicode():
# val = random.randint(0x4E00, 0x9FBF)
# return unichr(val)
#
# # 随机汉字
# def GB2312():
# head = random.randint(0xB0, 0xCF)
# body = random.randint(0xA, 0xF)
# tail = random.randint(0, 0xF)
# val = ( head << 8 ) | (body << 4) | tail
# str = "%x" % val
# return str.decode('hex').decode('gb2312')

# 随机字母
def rand_char():
return chr(random.randint(65, 90))

# 随机字母或者数字
def rand_choice():
str = 'abcdefghigklmnopqrstuvwxyzQWERTYUIOPASDFGHJKLZXCVBNM1234567890'
return random.choice(str)
11 changes: 11 additions & 0 deletions xyjxyf/0011/0011.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
北京
程序员
公务员
领导
牛比
牛逼
你娘
你妈
love
sex
jiangge
5 changes: 5 additions & 0 deletions xyjxyf/0014/student.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"1":["张三",150,120,100],
"2":["李四",90,99,95],
"3":["王五",60,66,68]
}
Binary file added xyjxyf/0014/student.xls
Binary file not shown.
5 changes: 5 additions & 0 deletions xyjxyf/0015/city.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"1" : "上海",
"2" : "北京",
"3" : "成都"
}
Binary file added xyjxyf/0015/city.xls
Binary file not shown.
5 changes: 5 additions & 0 deletions xyjxyf/0016/numbers.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
[1, 82, 65535],
[20, 90, 13],
[26, 809, 1024]
]
Binary file added xyjxyf/0016/numbers.xls
Binary file not shown.
Binary file added xyjxyf/0017/student.xls
Binary file not shown.
14 changes: 14 additions & 0 deletions xyjxyf/0017/student.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" ?>
<root>
<students>
<!--
学生信息表
"id" : [名字, 数学, 语文, 英文]
-->
{
3: ['王五', 60.0, 66.0, 68.0]
2: ['李四', 90.0, 99.0, 95.0]
1: ['张三', 150.0, 120.0, 100.0]
}
</students>
</root>
Binary file added xyjxyf/0018/city.xls
Binary file not shown.
13 changes: 13 additions & 0 deletions xyjxyf/0018/city.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version='1.0' encoding='UTF-8'?>
<root>
<citys>
{
3: ['成都']
2: ['北京']
1: ['上海']
}
<!--
城市信息
-->
</citys>
</root>
Binary file added xyjxyf/0019/numbers.xls
Binary file not shown.
13 changes: 13 additions & 0 deletions xyjxyf/0019/numbers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version='1.0' encoding='UTF-8'?>
<root>
<numbers>
[
[1.0, 82.0, 65535.0],
[20.0, 90.0, 13.0],
[26.0, 809.0, 1024.0],
]
<!--
数字信息
-->
</numbers>
</root>
Binary file added xyjxyf/0020/0020.xls
Binary file not shown.
78 changes: 78 additions & 0 deletions xyjxyf/0025/voice_open_browser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# encoding = utf-8

# use pyAudio
# brew install portaudio
# pip install pyaudio

import wave, pyaudio
from datetime import datetime
from tools import dxbaiduaudio
import webbrowser

CHUNK = 1024
FORMAT = pyaudio.paInt16
RATE = 8000
CHANNELS = 1
RECORD_SECONDS = 5

def record_wave(to_dir=None):
if to_dir is None:
to_dir = "./"

pa = pyaudio.PyAudio()
stream = pa.open(format = FORMAT,
channels = CHANNELS,
rate = RATE,
input = True,
frames_per_buffer = CHUNK)

print("* recording")

save_buffer = []
for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
audio_data = stream.read(CHUNK)
save_buffer.append(audio_data)

print("* done recording")

# stop
stream.stop_stream()
stream.close()
pa.terminate()

# wav path
file_name = datetime.now().strftime("%Y-%m-%d_%H_%M_%S")+".wav"
if to_dir.endswith('/'):
file_path = to_dir + file_name
else:
file_path = to_dir + "/" + file_name

# save file
wf = wave.open(file_path, 'wb')
wf.setnchannels(CHANNELS)
wf.setsampwidth(pa.get_sample_size(FORMAT))
wf.setframerate(RATE)
# join 前的类型
wf.writeframes(b''.join(save_buffer))
wf.close()

return file_path

def browser_open_text(text):
if text is None:
return

url = "http://www.baidu.com"
if text.startswith("谷歌") or text.startswith("google"):
url = "http://www.google.com"
elif text.startswith("必应") or text.startswith("bing"):
url = "http://cn.bing.com"

webbrowser.open_new_tab(url)

if __name__ == "__main__":
to_dir = "./"
file_path = record_wave(to_dir)

text = dxbaiduaudio.wav_to_text(file_path)
browser_open_text(text)
55 changes: 55 additions & 0 deletions xyjxyf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
xyjxyf Notes
======
## Mac上安装Redis

1. 下载源文件

[redis-3.0.7.rar.gz](http://download.redis.io/releases/)

2. 安装

```
$ tar -zxvf redis-3.0.6.tar.gz
$ cd redis-3.0.7
$ make test
$ make install
```

3. 配置

```
$ vi ./redis.conf

# 设置为后台运行
daemonize yes

# 设置pid文件位置
pidfile /usr/local/redis/redis.pid

# 连接超时时间设置为120秒
timeout 120

# 设置日志级别
loglevel debug

# 设置日志文件位置
logfile "/usr/local/redis/log/6379.log"

# 数据文件所在目录
dir /usr/local/redis/data/6379
```

4. 启动redis服务器

```
$ ./redis-server
```

5. 安装Python的Redis模块

我的mac安装了python双版本,用python3


```
$ pip3 install redis
```
Loading