<commit_before><?php declare(strict_types=1);
/**
 * @author    <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2017, <NAME>
 * @link      http://www.penguin33.ru
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Phestival\Speaker;

use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\Process;

/**
 * Speaker
 */
class Speaker
{
    /**
     * @var \Symfony\Component\Filesystem\Filesystem
     */
    private $filesystem;

    /**
     * @var string
     */
    private $playCommand;

    /**
     * @var string
     */
    private $synthesizeCommand;

    /**
     * @var string
     */
    private $tmpFileDir;

    /**
     * @var string|null
     */
    private $tmpFilePathname;

    /**
     * @param \Symfony\Component\Filesystem\Filesystem $filesystem        Filesystem
     * @param string                                   $playCommand       Play command
     * @param string                                   $synthesizeCommand Speech synthesize command
     * @param string                                   $tmpFileDir        Directory for storing temporary files
     */
    public function __construct(Filesystem $filesystem, string $playCommand, string $synthesizeCommand, string $tmpFileDir)
    {
        $this->filesystem = $filesystem;
        $this->playCommand = $playCommand;
        $this->synthesizeCommand = $synthesizeCommand;
        $this->tmpFileDir = $tmpFileDir;

        $this->tmpFilePathname = null;
    }

    public function __destruct()
    {
        $this->cleanup();
    }

    /**
     * @param string $text Text to speak
     */
    public function speak(string $text)
    {
        if (!empty($text)) {<commit_msg>Handle SIGINT in the speaker.<commit_after><?php declare(strict_types=1);
/**
 * @author    <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2017, <NAME>
 * @link      http://www.penguin33.ru
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Phestival\Speaker;

use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\Process;

/**
 * Speaker
 */
class Speaker
{
    /**
     * @var \Symfony\Component\Filesystem\Filesystem
     */
    private $filesystem;

    /**
     * @var string
     */
    private $playCommand;

    /**
     * @var string
     */
    private $synthesizeCommand;

    /**
     * @var string
     */
    private $tmpFileDir;

    /**
     * @var string|null
     */
    private $tmpFilePathname;

    /**
     * @param \Symfony\Component\Filesystem\Filesystem $filesystem        Filesystem
     * @param string                                   $playCommand       Play command
     * @param string                                   $synthesizeCommand Speech synthesize command
     * @param string                                   $tmpFileDir        Directory for storing temporary files
     */
    public function __construct(Filesystem $filesystem, string $playCommand, string $synthesizeCommand, string $tmpFileDir)
    {
        $this->filesystem = $filesystem;
        $this->playCommand = $playCommand;
        $this->synthesizeCommand = $synthesizeCommand;
        $this->tmpFileDir = $tmpFileDir;

        $this->tmpFilePathname = null;

        pcntl_signal(SIGINT, [$this, '__destruct']);
    }

    public function __destruct()
    {
        $this->cleanup();
    }

    /**
     * @param string $text Text to speak
     */
    public function speak(string $text)
    {
        if (!empty($text)) {
{'fraction_non_alphanumeric': 0.1124930901050304, 'fraction_numerical': 0.003869541182974019, 'mean_word_length': 2.072156196943973, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3792901', 'n_tokens_mistral': 1053, 'n_tokens_neox': 983, 'n_words': 245}