|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Cion\TextToSpeech\Providers; |
|
4
|
|
|
|
|
5
|
|
|
use Cion\TextToSpeech\Contracts\Formatter; |
|
6
|
|
|
use Cion\TextToSpeech\Contracts\Source; |
|
7
|
|
|
use Cion\TextToSpeech\Facades\TextToSpeech; |
|
8
|
|
|
use Cion\TextToSpeech\TextToSpeechManager; |
|
9
|
|
|
use Illuminate\Support\ServiceProvider; |
|
10
|
|
|
|
|
11
|
|
|
class TextToSpeechServiceProvider extends ServiceProvider |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* Bootstrap the application services. |
|
15
|
|
|
*/ |
|
16
|
|
|
public function boot() |
|
17
|
|
|
{ |
|
18
|
|
|
if ($this->app->runningInConsole()) { |
|
19
|
|
|
$this->publishes([ |
|
20
|
|
|
__DIR__.'/../../config/config.php' => config_path('tts.php'), |
|
21
|
|
|
], 'config'); |
|
22
|
|
|
} |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Register the application services. |
|
27
|
|
|
*/ |
|
28
|
|
|
public function register() |
|
29
|
|
|
{ |
|
30
|
|
|
$this->mergeConfigFrom(__DIR__.'/../../config/config.php', 'tts'); |
|
31
|
|
|
|
|
32
|
|
|
$this->registerTextToSpeechManager(); |
|
33
|
|
|
|
|
34
|
|
|
$this->registerAliases(); |
|
35
|
|
|
|
|
36
|
|
|
$this->bindFilenameFormatter(); |
|
37
|
|
|
|
|
38
|
|
|
$this->bindSource(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Registers the Text to speech manager. |
|
43
|
|
|
* |
|
44
|
|
|
* @return void |
|
45
|
|
|
*/ |
|
46
|
|
|
protected function registerTextToSpeechManager() |
|
47
|
|
|
{ |
|
48
|
|
|
$this->app->singleton('tts', function ($app) { |
|
49
|
|
|
return new TextToSpeechManager($app); |
|
50
|
|
|
}); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Register aliases. |
|
55
|
|
|
* |
|
56
|
|
|
* @return void |
|
57
|
|
|
*/ |
|
58
|
|
|
protected function registerAliases() |
|
59
|
|
|
{ |
|
60
|
|
|
$this->app->alias(TextToSpeech::class, 'TTS'); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Binds the filename formatter. |
|
65
|
|
|
* |
|
66
|
|
|
* @return void |
|
67
|
|
|
*/ |
|
68
|
|
|
protected function bindFilenameFormatter() |
|
69
|
|
|
{ |
|
70
|
|
|
$this->app->bind(Formatter::class, config('tts.audio.formatter')); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Binds the default source. |
|
75
|
|
|
* |
|
76
|
|
|
* @return void |
|
77
|
|
|
*/ |
|
78
|
|
|
protected function bindSource() |
|
79
|
|
|
{ |
|
80
|
|
|
$this->app->bind(Source::class, config('tts.sources.' . config('tts.default_source'))); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Get the services provided by the provider. |
|
85
|
|
|
* |
|
86
|
|
|
* @return array |
|
87
|
|
|
*/ |
|
88
|
|
|
public function provides() |
|
89
|
|
|
{ |
|
90
|
|
|
return [ |
|
91
|
|
|
'tts', |
|
92
|
|
|
]; |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|