uguis

package module
v0.0.0-...-d63e9d0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2014 License: MIT Imports: 15 Imported by: 0

README

Uguis - Twitter音声読み上げツール

概要

Uguisは、Twitterのツイートを自動的に取得して音声で読み上げるコマンドラインツールです。VoiceText Web APIを利用してツイートのテキスト情報を音声ファイルに変換します。

インストール

方法1. 実行ファイルのインストール

準備中

方法2. ソースコードからのインストール
$ go get github.com/yosssi/uguis/...

インストールが正常に実施されたことの確認

$ uguis -v
Uguis vX.X.X

起動に必要な認証情報の取得

以下のAPIの認証情報を取得してください。

  • Twitter REST API(取得する認証情報:APIキー、APIシークレット、アクセストークン、アクセストークンシークレット)

  • VoiceText Web API(取得する認証情報:APIキー)

起動方法

起動時に入力するコマンドは以下の通りです。

$ uguis \
-twitter-api-key=TwitterAPIキー \
-twitter-api-secret=TwitterAPIシークレット \
-twitter-access-token=Twitterアクセストークン \
-twitter-access-token-secret=Twitterアクセストークンシークレット \
-voicetext-api-key=VoiceTextAPIキー \
-p=音声ファイル再生コマンド

コマンド入力例を以下に記載します。

$ uguis \
-twitter-api-key=aaaa \
-twitter-api-secret=bbbb \
-twitter-access-token=cccc \
-twitter-access-token-secret=dddd \
-voicetext-api-key=eeee \
-p=afplay

取得・読み上げることのできるツイート

  • 自分のタイムラインに表示されるツイート
  • 特定のキーワードに合致するツイート(準備中)

ToDo

Issuesをご覧ください。

Documentation

Overview

Package uguis provides tweet-to-speech command line tool.

Index

Constants

View Source
const (
	LogLevelTRACE = iota
	LogLevelDEBUG
	LogLevelINFO
	LogLevelWARN
	LogLevelERROR
	LogLevelFATAL
)

Log levels

View Source
const Version = "Uguis v0.0.1"

Version is the version of Uguis.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application struct {
	// Hostname represents the hostname.
	Hostname string
	// CPUs represents the maximum number of CPUs.
	CPUs int
}

Application represents an application.

func NewApplication

func NewApplication(opts *ApplicationOptions) *Application

NewApplication creates and returns an application.

type ApplicationOptions

type ApplicationOptions struct {
	// Hostname represents the host name.
	Hostname string
	// CPUs represents the maximum number of CPUs.
	CPUs int
}

ApplicationOptions represents options for an application.

type BoltDBOptions

type BoltDBOptions struct {
	// Path represents a Bolt database file path.
	Path string
}

BoltDBOptions represents options for a Bolt database.

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller represents a controller.

func NewController

func NewController(
	app *Application,
	lgr Logger,
	twitterClient TwitterClient,
	voicetextClient VoicetextClient,
	fileWriter FileWriter,
	player Player,
) *Controller

NewController creates and returns a controller.

func (*Controller) Exec

func (ctrl *Controller) Exec()

Exec executes the controller's main process.

type DB

type DB interface {
	// Get gets a value from a database.
	Get(bucketName, key []byte) ([]byte, error)
	// Put puts the key/value to a database.
	Put(bucketName, key, value []byte) error
	// Close closes the database.
	Close() error
}

DB is an interface for storing data.

func NewBoltDB

func NewBoltDB(opts *BoltDBOptions) (DB, error)

NewBoltDB creates and returns a Bolt database.

type DBReadWriter

type DBReadWriter interface {
	// Get gets a value from a database.
	Get(bucketName, key []byte) ([]byte, error)
	// Put puts the key/value to a database.
	Put(bucketName, key, value []byte) error
	// Close closes the database read writer's process.
	Close() error
}

DBReadWriter is an interface for reading/writing data from/to the databse.

func NewSimpleDBReadWriter

func NewSimpleDBReadWriter(db DB, opts *SimpleDBReadWriterOptions) DBReadWriter

NewSimpleDBReadWriter creates and returns a simple database read writer.

type FileWriter

type FileWriter interface {
	// Write writes a file.
	Write(req FileWriterRequest)
	// Close closes the file writer.
	Close() error
	// ResC returns a response channel.
	ResC() <-chan FileWriterResponse
}

FileWriter is an interface for writing a file.

func NewSimpleFileWriter

func NewSimpleFileWriter(
	app *Application,
	lgr Logger,
	opts *SimpleFileWriterOptions,
) FileWriter

NewSimpleFileWriter creates and returns a simple file writer.

type FileWriterRequest

type FileWriterRequest struct {
	// contains filtered or unexported fields
}

FileWriterRequest represents a file writer request.

func NewFileWriterRequest

func NewFileWriterRequest(tweet Tweet, file file) FileWriterRequest

NewFileWriterRequest creates and returns a file writer request.

type FileWriterResponse

type FileWriterResponse struct {
	// contains filtered or unexported fields
}

FileWriterResponse represents a file writer response.

func NewFileWriterResponse

func NewFileWriterResponse(tweet Tweet, path string) FileWriterResponse

NewFileWriterResponse creates and returns a file writer response.

type Log

type Log struct {
	// Level represents a log level.
	Level uint8
	// AppName represents an application name which creates the log.
	Hostname string
	// ServiceName represents a service name which creates the log.
	ServiceName string
	// Msg represents a log message.
	Msg string
	// Time represent a log time.
	Time time.Time
}

Log represents a log.

func NewLog

func NewLog(level uint8, hostname string, serviceName string, msg string) Log

NewLog creates and returns a log.

func (Log) String

func (lg Log) String() string

String returns a log string.

type Logger

type Logger interface {
	// Print prints a log.
	Print(lg Log)
	// Close closes the logger.
	Close() error
}

Logger is an interface for prining a log.

func NewSimpleLogger

func NewSimpleLogger(opts *SimpleLoggerOptions) Logger

NewSimpleLogger creates and returns a simple logger.

type Player

type Player interface {
	// Play plays a sound file.
	Play(path PlayerRequest)
	// Close closes the player.
	Close() error
	// ResC returns a response channel.
	ResC() <-chan PlayerResponse
}

Player is an interface for playing a sound file.

func NewSimplePlayer

func NewSimplePlayer(
	command string,
	app *Application,
	lgr Logger,
	opts *SimplePlayerOptions,
) Player

NewSimplePlayer creates and returns a simple player.

type PlayerRequest

type PlayerRequest struct {
	// contains filtered or unexported fields
}

PlayerRequest represents a player request.

func NewPlayerRequest

func NewPlayerRequest(tweet Tweet, path string) PlayerRequest

NewPlayerRequest creates and returns a player request.

type PlayerResponse

type PlayerResponse struct {
	// contains filtered or unexported fields
}

PlayerResponse represents a player response.

func NewPlayerResponse

func NewPlayerResponse(tweet Tweet, path string) PlayerResponse

NewPlayerResponse creates and returns a player response.

type SimpleDBReadWriterOptions

type SimpleDBReadWriterOptions struct {
}

SimpleDBReadWriterOptions represents options for a simple database read writer.

type SimpleFileWriterOptions

type SimpleFileWriterOptions struct {
	// ReqCBfSize represents a buffer size of a request channel.
	ReqCBfSize uint32
	// ResCBfSize represents a buffer size of a response channel.
	ResCBfSize uint32
}

SimpleFileWriterOptions represents options for a simple file writer.

type SimpleLoggerOptions

type SimpleLoggerOptions struct {
	// LevelStr represents a log level string.
	LevelStr string
	// LogCBfSize represents a buffer size of a log channel.
	LogCBfSize uint32
}

SimpleLoggerOptions represents options for a simple logger.

type SimplePlayerOptions

type SimplePlayerOptions struct {
	// ReqCBfSize represents a buffer size of a request channel.
	ReqCBfSize uint32
	// ResCBfSize represents a buffer size of a response channel.
	ResCBfSize uint32
}

SimplePlayerOptions represents options for a simple player.

type SimpleTwitterClientOptions

type SimpleTwitterClientOptions struct {
	// ReqCBfSize represents a buffer size of a request channel.
	ReqCBfSize uint32
	// ResCBfSize represents a buffer size of a response channel.
	ResCBfSize uint32
}

SimpleTwitterClientOptions represents options for a simple twitter client.

type SimpleVoicetextClientOptions

type SimpleVoicetextClientOptions struct {
	// ReqCBfSize represents a buffer size of a request channel.
	ReqCBfSize uint32
	// ResCBfSize represents a buffer size of a response channel.
	ResCBfSize uint32
}

SimpleVoicetextClientOptions represents options for a simple voicetext client.

type Tweet

type Tweet struct {
	Contributors interface{} `json:"contributors"`
	Coordinates  interface{} `json:"coordinates"`
	CreatedAt    string      `json:"created_at"`
	Entities     struct {
		Hashtags []struct {
			Indices []float64 `json:"indices"`
			Text    string    `json:"text"`
		} `json:"hashtags"`
		Symbols []interface{} `json:"symbols"`
		Urls    []struct {
			DisplayURL  string    `json:"display_url"`
			ExpandedURL string    `json:"expanded_url"`
			Indices     []float64 `json:"indices"`
			URL         string    `json:"url"`
		} `json:"urls"`
		UserMentions []interface{} `json:"user_mentions"`
	} `json:"entities"`
	FavoriteCount        float64     `json:"favorite_count"`
	Favorited            bool        `json:"favorited"`
	Geo                  interface{} `json:"geo"`
	ID                   float64     `json:"id"`
	IDStr                string      `json:"id_str"`
	InReplyToScreenName  interface{} `json:"in_reply_to_screen_name"`
	InReplyToStatusID    interface{} `json:"in_reply_to_status_id"`
	InReplyToStatusIDStr interface{} `json:"in_reply_to_status_id_str"`
	InReplyToUserID      interface{} `json:"in_reply_to_user_id"`
	InReplyToUserIDStr   interface{} `json:"in_reply_to_user_id_str"`
	Lang                 string      `json:"lang"`
	Place                interface{} `json:"place"`
	PossiblySensitive    bool        `json:"possibly_sensitive"`
	RetweetCount         float64     `json:"retweet_count"`
	Retweeted            bool        `json:"retweeted"`
	Source               string      `json:"source"`
	Text                 string      `json:"text"`
	Truncated            bool        `json:"truncated"`
	User                 struct {
		ContributorsEnabled bool   `json:"contributors_enabled"`
		CreatedAt           string `json:"created_at"`
		DefaultProfile      bool   `json:"default_profile"`
		DefaultProfileImage bool   `json:"default_profile_image"`
		Description         string `json:"description"`
		Entities            struct {
			Description struct {
				Urls []struct {
					DisplayURL  string    `json:"display_url"`
					ExpandedURL string    `json:"expanded_url"`
					Indices     []float64 `json:"indices"`
					URL         string    `json:"url"`
				} `json:"urls"`
			} `json:"description"`
			URL struct {
				Urls []struct {
					DisplayURL  string    `json:"display_url"`
					ExpandedURL string    `json:"expanded_url"`
					Indices     []float64 `json:"indices"`
					URL         string    `json:"url"`
				} `json:"urls"`
			} `json:"url"`
		} `json:"entities"`
		FavouritesCount                float64 `json:"favourites_count"`
		FollowRequestSent              bool    `json:"follow_request_sent"`
		FollowersCount                 float64 `json:"followers_count"`
		Following                      bool    `json:"following"`
		FriendsCount                   float64 `json:"friends_count"`
		GeoEnabled                     bool    `json:"geo_enabled"`
		ID                             float64 `json:"id"`
		IDStr                          string  `json:"id_str"`
		IsTranslationEnabled           bool    `json:"is_translation_enabled"`
		IsTranslator                   bool    `json:"is_translator"`
		Lang                           string  `json:"lang"`
		ListedCount                    float64 `json:"listed_count"`
		Location                       string  `json:"location"`
		Name                           string  `json:"name"`
		Notifications                  bool    `json:"notifications"`
		ProfileBackgroundColor         string  `json:"profile_background_color"`
		ProfileBackgroundImageURL      string  `json:"profile_background_image_url"`
		ProfileBackgroundImageURLHttps string  `json:"profile_background_image_url_https"`
		ProfileBackgroundTile          bool    `json:"profile_background_tile"`
		ProfileImageURL                string  `json:"profile_image_url"`
		ProfileImageURLHTTPS           string  `json:"profile_image_url_https"`
		ProfileLinkColor               string  `json:"profile_link_color"`
		ProfileSidebarBorderColor      string  `json:"profile_sidebar_border_color"`
		ProfileSidebarFillColor        string  `json:"profile_sidebar_fill_color"`
		ProfileTextColor               string  `json:"profile_text_color"`
		ProfileUseBackgroundImage      bool    `json:"profile_use_background_image"`
		Protected                      bool    `json:"protected"`
		ScreenName                     string  `json:"screen_name"`
		StatusesCount                  float64 `json:"statuses_count"`
		TimeZone                       string  `json:"time_zone"`
		URL                            string  `json:"url"`
		UtcOffset                      float64 `json:"utc_offset"`
		Verified                       bool    `json:"verified"`
	} `json:"user"`
}

Tweet represents a tweet.

type Tweets

type Tweets []Tweet

Tweets represents tweets.

type TwitterClient

type TwitterClient interface {
	// Call calls a Twitter API.
	Call(req twitterRequest)
	// Close closes the twitter client.
	Close() error
	// ResC returns a response channel.
	ResC() <-chan Tweet
}

TwitterClient is an interface for calling the Twitter APIs.

func NewSimpleTwitterClient

func NewSimpleTwitterClient(
	consumerKey string,
	consumerSecret string,
	accessToken string,
	accessTokenSecret string,
	app *Application,
	lgr Logger,
	opts *SimpleTwitterClientOptions,
) TwitterClient

NewSimpleTwitterClient creates and returns a simple Twitter client.

type VoicetextClient

type VoicetextClient interface {
	// TTS calls the Voicetext TTS API.
	TTS(req VoicetextTTSRequest)
	// Close closes the twitter client.
	Close() error
	// ResC returns a response channel.
	ResC() <-chan VoicetextTTSResponse
}

VoicetextClient is an interface for calling Voicetext Web APIs.

func NewSimpleVoicetextClient

func NewSimpleVoicetextClient(
	apiKey string,
	app *Application,
	lgr Logger,
	opts *SimpleVoicetextClientOptions,
) VoicetextClient

NewSimpleVoicetextClient creates and returns a simple voicetext client.

type VoicetextTTSRequest

type VoicetextTTSRequest struct {
	// contains filtered or unexported fields
}

VoicetextTTSRequest represents a voicetext request.

func NewVoicetextTTSRequest

func NewVoicetextTTSRequest(tweet Tweet, opts *voicetext.TTSOptions) VoicetextTTSRequest

NewVoicetextTTSRequest creates and returns a voicetext request.

type VoicetextTTSResponse

type VoicetextTTSResponse struct {
	// contains filtered or unexported fields
}

VoicetextTTSResponse represents a voicetext response.

func NewVoicetextTTSResponse

func NewVoicetextTTSResponse(tweet Tweet, result *voicetext.Result) VoicetextTTSResponse

NewVoicetextTTSResponse creates and returns a a voicetext response.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL