-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore_cmd.py
67 lines (57 loc) · 2.05 KB
/
core_cmd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/3/26 10:40
# @Author : Wendyltanpcy
# @File : core_cmd.py
# @Software: PyCharm
import click
from violet import *
from violet.wilove import readQuote, getRanQuote
@click.group()
def violet():
pass
@violet.command()
@click.option('--name',prompt='Enter your name here',
help='Greet to given name')
def greet(name):
click.echo('Hello %s' % name)
@violet.command()
@click.option('--receiver',prompt='enter the receiver here',help='add your receiver')
@click.option('--subject',prompt='enter the subject here',help='add your subject')
@click.option('--mailbody',prompt='enter the body here',help='add your mail body')
def email(receiver,mailbody,subject):
if hp.check_email_valid(receiver):
# email is valid
e.send_common_mail(receiver,mailbody,subject)
else:
click.echo('Invalid email format!try again...')
@violet.command()
@click.option('--filename',prompt='enter the audio filename',help='audio file name')
def record(filename):
rec = rc()
for example, time_count in rec.record():
# 显示当前采样率
click.echo(example)
click.echo(time_count)
filename = filename + '.wav'
rec.savewav('violet/wave/'+filename)
click.echo('audio file save success!')
@violet.command()
@click.option('--audiopath',prompt='enter audio filename ,make sure you have put in under wave dir',help='tranform audio to textfile')
def audio2text(audiopath):
if not audiopath.endswith('.wav'):
click.echo('you offered invalid audio filename!')
else:
if sr.write_text_file(audiopath):
click.echo('text file generate success!check your file under speech/')
else:
click.echo('something wrong happened,please try again')
@violet.command()
@click.option('--love',help='Don\'t know what is love ? Violet chan will tell you')
def whatislove(love):
# get only one at a time
quotes = readQuote()
if quotes != None:
click.echo(getRanQuote(quotes))
if __name__ == '__main__':
violet()