Code Duplication    Length = 37-38 lines in 2 locations

src/Driver/Google.php 1 location

@@ 8-45 (lines=38) @@
5
6
use TTS\Helper\SplitterText;
7
8
class Google extends AbstractAdapter
9
{
10
    protected $name = 'Google';
11
    protected $voice = 'famale';
12
13
    protected $languageMap = [
14
        'en_GB' => 'en',
15
        'en_EN' => 'en',
16
        'ru_RU' => 'ru'
17
    ];
18
19
20
21
    public function make($text, $fileName)
22
    {
23
        $sp = new SplitterText();
24
        $text = iconv('UTF-8', 'UTF-8', $text);
25
26
        $lines = $sp->split($text, 100);
27
        $content = '';
28
        foreach ($lines as $line) {
29
            $query = [
30
                'tl'        => $this->getLanguage(),
31
                'ttsspeed'  => $this->getSpeed(),
32
                'q'         => $line,
33
                'ie'        => 'UTF-8',
34
                'client'    => 't'
35
            ];
36
            $content .= $this->reguestGet($query);
37
        }
38
        return $content;
39
    }
40
41
    public function getUri()
42
    {
43
        return 'https://translate.google.ru/translate_tts';
44
    }
45
}
46

src/Driver/iSpeech.php 1 location

@@ 15-51 (lines=37) @@
12
13
use TTS\Helper\SplitterText;
14
15
class iSpeech extends AbstractAdapter
16
{
17
    protected $name = 'iSpeech';
18
    protected $voice = 'male';
19
20
    protected $speed = 0;
21
22
    protected $languageMap = [
23
        'en_GB' => 'en',
24
        'en_EN' => 'en',
25
        'ru_RU' => 'rurussianmale'
26
    ];
27
28
    public function getUri()
29
    {
30
        return 'http://www.ispeech.org/p/generic/getaudio';
31
    }
32
33
    public function make($text, $fileName)
34
    {
35
        $sp = new SplitterText();
36
        $text = iconv('UTF-8', 'UTF-8', $text);
37
38
        $lines = $sp->split($text, 100);
39
        $content = '';
40
        foreach ($lines as $line) {
41
            $query = [
42
                'voice'     => $this->getLanguage(),
43
                'speed'     => $this->getSpeed(),
44
                'text'      => $line,
45
                'action'    => 'convert'
46
            ];
47
            $content .= $this->reguestGet($query);
48
        }
49
        return $content;
50
    }
51
}
52